Search in sources :

Example 1 with LogHelper

use of net.silentchaos512.lib.util.LogHelper in project SilentGems by SilentChaos512.

the class TileTeleporter method linkTeleporters.

public boolean linkTeleporters(EntityPlayer player, World world, BlockPos pos, ItemStack heldItem, EnumHand hand) {
    if (world.isRemote) {
        return true;
    }
    LogHelper log = SilentGems.logHelper;
    LocalizationHelper loc = SilentGems.localizationHelper;
    ItemTeleporterLinker linker = ModItems.teleporterLinker;
    if (StackHelper.isEmpty(heldItem) || heldItem.getItem() != linker) {
        log.warning("TileTeleporter.linkTeleporters: heldItem is not a linker?");
        return false;
    }
    if (linker.isLinked(heldItem)) {
        // Active state: link teleporters and set inactive.
        DimensionalPosition position1 = linker.getLinkedPosition(heldItem);
        DimensionalPosition position2 = new DimensionalPosition(pos, player.dimension);
        if (position1 == null) {
            log.warning("Teleporter Linker tried to link with no position set?");
            return true;
        }
        TileTeleporter tile1 = (TileTeleporter) player.getServer().getWorld(position1.dim).getTileEntity(position1.toBlockPos());
        TileTeleporter tile2 = (TileTeleporter) player.getServer().getWorld(position2.dim).getTileEntity(position2.toBlockPos());
        if (tile1 == null || tile2 == null) {
            // Could not find a teleporter?
            ChatHelper.sendMessage(player, loc.getBlockSubText(Names.TELEPORTER, "LinkFail"));
            log.warning("Could not find teleporter when linking:" + "\nTeleporter1 @ " + position1.toString() + "\nTeleporter2 @ " + position2.toString());
            linker.setLinked(heldItem, false);
            return false;
        }
        // Create "link"
        tile1.destination = position2;
        tile2.destination = position1;
        ChatHelper.sendMessage(player, loc.getBlockSubText(Names.TELEPORTER, "LinkSuccess"));
        linker.setLinked(heldItem, false);
        tile1.markDirty();
        tile2.markDirty();
    } else {
        // Inactive state: set active and location.
        linker.setLinkedPosition(heldItem, new DimensionalPosition(pos, player.dimension));
        linker.setLinked(heldItem, true);
        ChatHelper.sendMessage(player, loc.getBlockSubText(Names.TELEPORTER, "LinkStart"));
    }
    return true;
}
Also used : DimensionalPosition(net.silentchaos512.lib.util.DimensionalPosition) LogHelper(net.silentchaos512.lib.util.LogHelper) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper) ItemTeleporterLinker(net.silentchaos512.gems.item.ItemTeleporterLinker)

Example 2 with LogHelper

use of net.silentchaos512.lib.util.LogHelper in project SilentGems by SilentChaos512.

the class MessageItemRename method handleMessage.

@Override
public // @SideOnly(Side.SERVER)
IMessage handleMessage(MessageContext context) {
    LogHelper log = SilentGems.logHelper;
    if (context.side != Side.SERVER) {
        log.warning("Wrong side!");
        return null;
    }
    EntityPlayer player = context.getServerHandler().player;
    ItemStack stack = player.inventory.getStackInSlot(slot);
    if (player.getName().equals(playerName)) {
        if (StackHelper.isEmpty(stack)) {
            log.warning("    ItemStack is null!");
            return null;
        } else if (!stack.getUnlocalizedName().equals(unlocalizedName)) {
            log.warning("    Unlocalized names do not match! Did the tool change slots?");
            return null;
        }
        stack.setStackDisplayName(newItemName);
        // Cleanup the temporary part list.
        if (stack.hasTagCompound() && stack.getTagCompound().hasKey(ToolHelper.NBT_TEMP_PARTLIST))
            stack.getTagCompound().removeTag(ToolHelper.NBT_TEMP_PARTLIST);
    }
    return null;
}
Also used : LogHelper(net.silentchaos512.lib.util.LogHelper) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 3 with LogHelper

use of net.silentchaos512.lib.util.LogHelper in project SilentGems by SilentChaos512.

the class ToolModel method getQuads.

@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
    LogHelper log = SilentGems.logHelper;
    if (tool == null) {
        return new ArrayList<BakedQuad>();
    }
    if (modelManager == null) {
        modelManager = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager();
    }
    List<BakedQuad> quads = Lists.newArrayList();
    ModelResourceLocation location;
    IBakedModel model;
    IBakedModel rodModel = null;
    Item item = tool.getItem();
    // Invalid tools models.
    if (ToolHelper.getMaxDamage(tool) <= 0 && tool.getItem() instanceof IRegistryObject) {
        String name = ((IRegistryObject) tool.getItem()).getName();
        location = new ModelResourceLocation(SilentGems.MODID + ":" + name.toLowerCase() + "/_error", "inventory");
        model = modelManager.getModel(location);
        if (model != null) {
            quads.addAll(model.getQuads(state, side, rand));
        }
        return quads;
    }
    for (ToolPartPosition partPos : ToolPartPosition.values()) {
        // Scepter rods on top of head.
        if (tool.getItem() instanceof ItemGemScepter) {
            if (partPos == ToolPartPosition.ROD) {
                location = ToolRenderHelper.getInstance().getModel(tool, partPos);
                rodModel = modelManager.getModel(location);
                continue;
            } else if (partPos == ToolPartPosition.ROD_DECO) {
                quads.addAll(rodModel.getQuads(state, side, rand));
            }
        }
        // Normal logic.
        location = ToolRenderHelper.getInstance().getModel(tool, partPos);
        // debug += partPos + ": " + (location == null ? "null" : location.toString()) + "\n";
        if (location != null) {
            model = modelManager.getModel(location);
            if (model != null) {
                quads.addAll(model.getQuads(state, side, rand));
            }
        }
    }
    if (ModuleAprilTricks.instance.isEnabled() && ModuleAprilTricks.instance.isRightDay()) {
        model = modelManager.getModel(ToolRenderHelper.getInstance().modelGooglyEyes);
        quads.addAll(model.getQuads(state, side, rand));
    }
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ItemGemScepter(net.silentchaos512.gems.item.tool.ItemGemScepter) Item(net.minecraft.item.Item) IRegistryObject(net.silentchaos512.lib.registry.IRegistryObject) ToolPartPosition(net.silentchaos512.gems.api.lib.ToolPartPosition) LogHelper(net.silentchaos512.lib.util.LogHelper) ArrayList(java.util.ArrayList) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Aggregations

LogHelper (net.silentchaos512.lib.util.LogHelper)3 ArrayList (java.util.ArrayList)1 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 ToolPartPosition (net.silentchaos512.gems.api.lib.ToolPartPosition)1 ItemTeleporterLinker (net.silentchaos512.gems.item.ItemTeleporterLinker)1 ItemGemScepter (net.silentchaos512.gems.item.tool.ItemGemScepter)1 IRegistryObject (net.silentchaos512.lib.registry.IRegistryObject)1 DimensionalPosition (net.silentchaos512.lib.util.DimensionalPosition)1 LocalizationHelper (net.silentchaos512.lib.util.LocalizationHelper)1