diff --git a/src/main/java/makeo/gadomancy/client/ClientProxy.java b/src/main/java/makeo/gadomancy/client/ClientProxy.java index 7c0165f..d1e2779 100644 --- a/src/main/java/makeo/gadomancy/client/ClientProxy.java +++ b/src/main/java/makeo/gadomancy/client/ClientProxy.java @@ -123,8 +123,8 @@ public class ClientProxy extends CommonProxy { ItemRenderStoneMachine itemRenderStoneMachine = new ItemRenderStoneMachine(); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RegisteredBlocks.blockStoneMachine), itemRenderStoneMachine); - itemRenderStoneMachine.registerRenderer(0, new TileManipulationFocus(0), renderTileManipulationFocus); - itemRenderStoneMachine.registerRenderer(3, new TileManipulationFocus(1), renderTileManipulationFocus); + itemRenderStoneMachine.registerRenderer(0, new TileManipulationFocus().setFociId(0), renderTileManipulationFocus); + itemRenderStoneMachine.registerRenderer(3, new TileManipulationFocus().setFociId(1), renderTileManipulationFocus); MinecraftForgeClient.registerItemRenderer(RegisteredItems.itemFamiliar, new ItemRenderFamiliar()); MinecraftForgeClient.registerItemRenderer(RegisteredItems.itemCreativeNode, new ItemCreativeNodeRenderer()); diff --git a/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileManipulationFocus.java b/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileManipulationFocus.java index 80b89ab..41c6cdb 100644 --- a/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileManipulationFocus.java +++ b/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileManipulationFocus.java @@ -21,6 +21,7 @@ public class RenderTileManipulationFocus extends TileEntitySpecialRenderer { private static final ModelFocusPortalPart PORTAL_FOCUS = new ModelFocusPortalPart(); public void renderTileEntityAt(TileManipulationFocus tile, double x, double y, double z, float partialTicks) { + if(tile.getFociId() == -1) return; GL11.glPushMatrix(); GL11.glTranslated(x, y, z); diff --git a/src/main/java/makeo/gadomancy/common/blocks/BlockNodeManipulator.java b/src/main/java/makeo/gadomancy/common/blocks/BlockNodeManipulator.java index bf6d617..f27a94f 100644 --- a/src/main/java/makeo/gadomancy/common/blocks/BlockNodeManipulator.java +++ b/src/main/java/makeo/gadomancy/common/blocks/BlockNodeManipulator.java @@ -84,7 +84,7 @@ public class BlockNodeManipulator extends BlockStoneDevice { if (tile.isMultiblockStructurePresent()) { String research = tile.getMultiblockType().getResearchNeeded(); if(!ResearchManager.isResearchComplete(player.getCommandSenderName(), research)) return false; - if (ThaumcraftApiHelper.consumeVisFromWandCrafting(player.getCurrentEquippedItem(), player, RegisteredRecipes.costsNodeManipulatorMultiblock, true)) { + if (ThaumcraftApiHelper.consumeVisFromWandCrafting(player.getCurrentEquippedItem(), player, tile.getMultiblockType().getMultiblockCosts(), true)) { tile.formMultiblock(); return true; } diff --git a/src/main/java/makeo/gadomancy/common/blocks/BlockStoneMachine.java b/src/main/java/makeo/gadomancy/common/blocks/BlockStoneMachine.java index 1f36daf..20488fa 100644 --- a/src/main/java/makeo/gadomancy/common/blocks/BlockStoneMachine.java +++ b/src/main/java/makeo/gadomancy/common/blocks/BlockStoneMachine.java @@ -105,13 +105,13 @@ public class BlockStoneMachine extends Block { if (metadata == 15) { return new TileManipulatorPillar(); } else if (metadata == 0) { - return new TileManipulationFocus(0); + return new TileManipulationFocus(); } else if(metadata == 1) { return new TilePedestal(); } else if(metadata == 2) { return new TileBlockProtector(); } else if(metadata == 3) { - return new TileManipulationFocus(1); + return new TileManipulationFocus(); } return null; } @@ -159,7 +159,7 @@ public class BlockStoneMachine extends Block { dropBlockAsItem(world, x, y, z, metadata, 0); world.setBlockToAir(x, y, z); } - } else if (metadata == 0) { + } else if (metadata == 0 || metadata == 3) { if (world.getBlock(x, y - 1, z) != RegisteredBlocks.blockNodeManipulator || world.getBlockMetadata(x, y - 1, z) != 5) { dropBlockAsItem(world, x, y, z, metadata, 0); world.setBlockToAir(x, y, z); @@ -167,11 +167,21 @@ public class BlockStoneMachine extends Block { } } + @Override + public void onPostBlockPlaced(World world, int x, int y, int z, int metadata) { + if(metadata == 0 || metadata == 3) { + TileEntity te = world.getTileEntity(x, y, z); + if(te != null && te instanceof TileManipulationFocus) { + ((TileManipulationFocus) te).setFociId(metadata == 0 ? 0 : 1); + } + } + } + @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { int metadata = world.getBlockMetadata(x, y, z); - if(metadata == 0) { + if(metadata == 0 || metadata == 3) { if (world.getBlock(x, y - 1, z).equals(RegisteredBlocks.blockNodeManipulator) && world.getBlockMetadata(x, y - 1, z) == 5) { return world.getBlock(x, y - 1, z).onBlockActivated(world, x, y - 1, z, player, side, hitX, hitY, hitZ); } @@ -189,7 +199,7 @@ public class BlockStoneMachine extends Block { setBlockBounds(0, 0, 0, 1, 0.5f, 1); } else if (metadata == 11) { setBlockBounds(0.0F, -1.0F, 0.0F, 1.0F, -0.5F, 1.0F); - } else if (metadata == 0) { + } else if (metadata == 0 || metadata == 3) { setBlockBounds(3 / 16f, 0, 3 / 16f, 1 - (3 / 16f), 6 / 16f, 1 - (3 / 16f)); } else if(metadata == 1) { setBlockBounds(0.25f, 0, 0.25f, 0.75f, 0.99f, 0.75f); @@ -202,7 +212,7 @@ public class BlockStoneMachine extends Block { int metadata = world.getBlockMetadata(x, y, z); if (metadata == 11 || metadata == 15 || metadata == 1) { setBlockBounds(0, 0, 0, 1, 1, 1); - } else if (metadata == 0) { + } else if (metadata == 0 || metadata == 3) { setBlockBoundsBasedOnState(world, x, y, z); } super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, list, entity); diff --git a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileManipulationFocus.java b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileManipulationFocus.java index ece42a1..79163f6 100644 --- a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileManipulationFocus.java +++ b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileManipulationFocus.java @@ -1,25 +1,43 @@ package makeo.gadomancy.common.blocks.tiles; +import net.minecraft.nbt.NBTTagCompound; + /** * This class is part of the Gadomancy Mod * Gadomancy is Open Source and distributed under the * GNU LESSER GENERAL PUBLIC LICENSE * for more read the LICENSE file - *
+ * * Created by makeo @ 28.10.2015 16:27 */ public class TileManipulationFocus extends SynchronizedTileEntity { - private int fociId; - public TileManipulationFocus(int fociId) { - this.fociId = fociId; - } + + private int fociId = -1; + public int getFociId() { - return fociId; + return fociId == -1 ? blockMetadata != -1 ? blockMetadata == 0 ? 0 : 1 : -1 : fociId; + } + + public TileManipulationFocus setFociId(int fociId) { + this.fociId = fociId; + return this; } @Override public boolean canUpdate() { return false; } + + @Override + public void writeCustomNBT(NBTTagCompound compound) { + compound.setInteger("fociId", this.fociId); + super.writeCustomNBT(compound); + } + + @Override + public void readCustomNBT(NBTTagCompound compound) { + this.fociId = compound.getInteger("fociId"); + super.readCustomNBT(compound); + } } diff --git a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileNodeManipulator.java b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileNodeManipulator.java index 6e4067d..04c7569 100644 --- a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileNodeManipulator.java +++ b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileNodeManipulator.java @@ -10,6 +10,7 @@ import makeo.gadomancy.common.node.NodeManipulatorResult; import makeo.gadomancy.common.node.NodeManipulatorResultHandler; import makeo.gadomancy.common.registration.RegisteredBlocks; import makeo.gadomancy.common.registration.RegisteredMultiblocks; +import makeo.gadomancy.common.registration.RegisteredRecipes; import makeo.gadomancy.common.utils.MultiblockHelper; import makeo.gadomancy.common.utils.world.TCMazeHandler; import net.minecraft.entity.player.EntityPlayer; @@ -127,18 +128,14 @@ public class TileNodeManipulator extends TileWandPedestal implements IAspectCont TileEntity te = worldObj.getTileEntity(xCoord, yCoord + 2, zCoord); if(te == null || !(te instanceof TileExtendedNode)) return; - TileExtendedNode node = (TileExtendedNode) te; - List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).expand(15, 15, 15)); - if(!players.isEmpty()) { - EntityPlayer player = (EntityPlayer) players.get(0); - //TCMazeHandler.createSessionWaitForTeleport(player, (int) player.posX, (int) player.posY, (int) player.posZ); - } + worldObj.removeTileEntity(xCoord, yCoord + 2, zCoord); + worldObj.setBlockToAir(xCoord, yCoord + 2, zCoord); + worldObj.setBlock(xCoord, yCoord + 2, zCoord, RegisteredBlocks.blockAdditionalEldrichPortal); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); worldObj.markBlockForUpdate(xCoord, yCoord + 2, zCoord); markDirty(); - node.markDirty(); } private void manipulationTick() { @@ -295,7 +292,8 @@ public class TileNodeManipulator extends TileWandPedestal implements IAspectCont for(MultiblockHelper.IntVec3 v : compareableCompleteStructure.keySet()) { MultiblockHelper.BlockInfo info = compareableCompleteStructure.get(v); MultiblockHelper.BlockInfo restoreInfo = toRestore.get(v); - if(info.block == RegisteredBlocks.blockNode || info.block == Blocks.air || info.block == RegisteredBlocks.blockNodeManipulator || restoreInfo == null) continue; + if(info.block == RegisteredBlocks.blockNode || (info.block == RegisteredBlocks.blockStoneMachine && (info.meta == 0 || info.meta == 3)) + || info.block == Blocks.air || info.block == RegisteredBlocks.blockNodeManipulator) continue; int absX = v.x + xCoord; int absY = v.y + yCoord; int absZ = v.z + zCoord; @@ -326,7 +324,8 @@ public class TileNodeManipulator extends TileWandPedestal implements IAspectCont } for(MultiblockHelper.IntVec3 v : toBuild.keySet()) { MultiblockHelper.BlockInfo info = toBuild.get(v); - if(info.block == RegisteredBlocks.blockNode || info.block == Blocks.air || info.block == RegisteredBlocks.blockNodeManipulator) continue; + if(info.block == RegisteredBlocks.blockNode || (info.block == RegisteredBlocks.blockStoneMachine && (info.meta == 0 || info.meta == 3)) + || info.block == Blocks.air || info.block == RegisteredBlocks.blockNodeManipulator) continue; int absX = v.x + xCoord; int absY = v.y + yCoord; int absZ = v.z + zCoord; @@ -519,18 +518,23 @@ public class TileNodeManipulator extends TileWandPedestal implements IAspectCont public static enum MultiblockType { - NODE_MANIPULATOR(Gadomancy.MODID.toUpperCase() + ".NODE_MANIPULATOR"), - E_PORTAL_CREATOR(Gadomancy.MODID.toUpperCase() + ".NODE_MANIPULATOR"); //TODO Change sometime. + NODE_MANIPULATOR(Gadomancy.MODID.toUpperCase() + ".NODE_MANIPULATOR", RegisteredRecipes.costsNodeManipulatorMultiblock), + E_PORTAL_CREATOR(Gadomancy.MODID.toUpperCase() + ".NODE_MANIPULATOR", RegisteredRecipes.costsEldritchPortalCreatorMultiblock); //TODO Change sometime. private String research; + private AspectList costs; - private MultiblockType(String research) { + private MultiblockType(String research, AspectList costs) { this.research = research; + this.costs = costs; } public String getResearchNeeded() { return research; } + public AspectList getMultiblockCosts() { + return costs; + } } } diff --git a/src/main/java/makeo/gadomancy/common/events/EventHandlerEntity.java b/src/main/java/makeo/gadomancy/common/events/EventHandlerEntity.java index d718f67..1466542 100644 --- a/src/main/java/makeo/gadomancy/common/events/EventHandlerEntity.java +++ b/src/main/java/makeo/gadomancy/common/events/EventHandlerEntity.java @@ -2,12 +2,18 @@ package makeo.gadomancy.common.events; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import makeo.gadomancy.common.data.ModConfig; import makeo.gadomancy.common.familiar.FamiliarAIController; import makeo.gadomancy.common.utils.world.TCMazeHandler; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; +import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; +import thaumcraft.common.items.armor.Hover; /** * This class is part of the Gadomancy Mod @@ -40,4 +46,19 @@ public class EventHandlerEntity { } } + @SubscribeEvent + public void on(LivingEvent.LivingUpdateEvent event) { + if(event.entityLiving == null || !(event.entityLiving instanceof EntityPlayer)) return; + EntityPlayer player = (EntityPlayer)event.entity; + if ((event.entity.worldObj.provider.dimensionId == ModConfig.dimOuterId) && ((player.ticksExisted & 7) == 0) && ((player.capabilities.isFlying) || (Hover.getHover(player.getEntityId())))){ + player.capabilities.isFlying = false; + Hover.setHover(player.getEntityId(), false); + String msg = StatCollector.translateToLocal("tc.break.fly"); + if(player.capabilities.isCreativeMode) { + msg += " " + StatCollector.translateToLocal("gadomancy.eldritch.noflyCreative"); + } + player.addChatMessage(new ChatComponentText(EnumChatFormatting.ITALIC + "" + EnumChatFormatting.GRAY + msg)); + } + } + } diff --git a/src/main/java/makeo/gadomancy/common/events/EventHandlerWorld.java b/src/main/java/makeo/gadomancy/common/events/EventHandlerWorld.java index 6b95566..bdbea92 100644 --- a/src/main/java/makeo/gadomancy/common/events/EventHandlerWorld.java +++ b/src/main/java/makeo/gadomancy/common/events/EventHandlerWorld.java @@ -19,6 +19,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.Explosion; import net.minecraft.world.GameRules; @@ -31,6 +33,7 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.ExplosionEvent; import net.minecraftforge.event.world.WorldEvent; +import thaumcraft.common.config.ConfigBlocks; import thaumcraft.common.items.wands.ItemWandCasting; import thaumcraft.common.tiles.TileJarFillable; @@ -164,6 +167,12 @@ public class EventHandlerWorld { ((TileNodeManipulator) te).breakMultiblock(); } } + if (event.world.provider.dimensionId == ModConfig.dimOuterId) { + if(event.block == ConfigBlocks.blockEldritchNothing) { + event.setCanceled(true); + event.getPlayer().addChatMessage(new ChatComponentText(EnumChatFormatting.ITALIC + "" + EnumChatFormatting.GRAY + StatCollector.translateToLocal("gadomancy.eldritch.nobreakPortalNothing"))); + } + } } } diff --git a/src/main/java/makeo/gadomancy/common/registration/RegisteredRecipes.java b/src/main/java/makeo/gadomancy/common/registration/RegisteredRecipes.java index b56793f..801a1da 100644 --- a/src/main/java/makeo/gadomancy/common/registration/RegisteredRecipes.java +++ b/src/main/java/makeo/gadomancy/common/registration/RegisteredRecipes.java @@ -36,6 +36,7 @@ public class RegisteredRecipes { private RegisteredRecipes() {} public static AspectList costsNodeManipulatorMultiblock = new AspectList().add(Aspect.FIRE, 100).add(Aspect.WATER, 100).add(Aspect.EARTH, 100).add(Aspect.AIR, 100).add(Aspect.ORDER, 100).add(Aspect.ENTROPY, 100); + public static AspectList costsEldritchPortalCreatorMultiblock = new AspectList().add(Aspect.FIRE, 150).add(Aspect.WATER, 150).add(Aspect.EARTH, 150).add(Aspect.AIR, 150).add(Aspect.ORDER, 150).add(Aspect.ENTROPY, 150); public static List multiblockNodeManipulator; diff --git a/src/main/java/makeo/gadomancy/common/utils/world/TCMazeHandler.java b/src/main/java/makeo/gadomancy/common/utils/world/TCMazeHandler.java index 69e6eea..15b6f41 100644 --- a/src/main/java/makeo/gadomancy/common/utils/world/TCMazeHandler.java +++ b/src/main/java/makeo/gadomancy/common/utils/world/TCMazeHandler.java @@ -72,6 +72,7 @@ public class TCMazeHandler { if (!hasOpenSession(player)) { WorldUtil.tryTeleportBack((EntityPlayerMP) player, 0); ChunkCoordinates cc = out.getSpawnPoint(); + //TODO return something valid int y = w.getTopSolidOrLiquidBlock(cc.posX, cc.posZ); player.setPositionAndUpdate(cc.posX + 0.5, y, cc.posZ + 0.5); } diff --git a/src/main/resources/assets/gadomancy/lang/en_US.lang b/src/main/resources/assets/gadomancy/lang/en_US.lang index a09d248..bdb34c5 100644 --- a/src/main/resources/assets/gadomancy/lang/en_US.lang +++ b/src/main/resources/assets/gadomancy/lang/en_US.lang @@ -102,6 +102,9 @@ gadomancy.upgrades.runicshield=Runic Shield gadomancy.lore.stickyjar=Sticky gadomancy.lore.remotejar=ยง7Network: %s +gadomancy.eldritch.noflyCreative=(even in creative) +gadomancy.eldritch.nobreakPortalNothing=This portal cannot be broken + tile.BlockStickyJar.name=Sticky Jar tile.BlockArcaneDropper.name=Arcane Dropper tile.BlockInfusionClaw.name=Infusion Claw diff --git a/src/main/resources/assets/gadomancy/textures/models/manipulation_focus_1.png b/src/main/resources/assets/gadomancy/textures/models/manipulation_focus_1.png index ea273fe..8a93911 100644 Binary files a/src/main/resources/assets/gadomancy/textures/models/manipulation_focus_1.png and b/src/main/resources/assets/gadomancy/textures/models/manipulation_focus_1.png differ