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;
}
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;
}
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;
}
Aggregations