diff --git a/.gitignore b/.gitignore index c0d5e44..ad32e34 100644 --- a/.gitignore +++ b/.gitignore @@ -62,4 +62,5 @@ Temporary Items # ARL Symlinks api/ +libs/ /forgestore.jks diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index c5f3f6b..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "java.configuration.updateBuildConfiguration": "interactive" -} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 94d43a7..2ccbc23 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge' //Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. -version = "0.0.2" +version = "0.0.4" group = "me.itstheholyblack.vigilant_eureka" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "vigilant_eureka" @@ -21,7 +21,7 @@ compileJava { } minecraft { - version = "1.12.2-14.23.0.2491" + version = "1.12.2-14.23.4.2705" runDir = "run" // the mappings can be changed at any time, and must be in the following format. @@ -29,8 +29,17 @@ minecraft { // stable_# stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not always work. // simply re-run your setup task after changing the mappings to update your workspace. - mappings = "snapshot_20171108" + mappings = "snapshot_20180619" makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. + if (project.hasProperty('mc_username')) { + clientRunArgs += ['--username', project.mc_username] + if (project.hasProperty('mc_password')) { + clientRunArgs += ['--password', project.mc_password] + } + } + if (project.hasProperty('mc_uuid')) { + clientRunArgs += ['--uuid', project.mc_uuid] + } } dependencies { @@ -54,7 +63,7 @@ dependencies { // for more info... // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/dependency_management.html - + compile files('libs/Baubles-deobf.jar') } processResources { diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/Eureka.java b/src/main/java/me/itstheholyblack/vigilant_eureka/Eureka.java index c9d6370..02645c4 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/Eureka.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/Eureka.java @@ -7,7 +7,7 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION, certificateFingerprint = Reference.MOD_KEY, acceptedMinecraftVersions = "[1.12,)") +@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION, certificateFingerprint = Reference.MOD_KEY, acceptedMinecraftVersions = "[1.12,)", dependencies = Reference.DEPENDS) public class Eureka { @SidedProxy(clientSide = "me.itstheholyblack.vigilant_eureka.proxy.ClientProxy", serverSide = "me.itstheholyblack.vigilant_eureka.proxy.ServerProxy") diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/Reference.java b/src/main/java/me/itstheholyblack/vigilant_eureka/Reference.java index d3914cf..c16843a 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/Reference.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/Reference.java @@ -1,8 +1,13 @@ package me.itstheholyblack.vigilant_eureka; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + public class Reference { - public static final String MOD_NAME = "Vigilant Eureka"; + static final String MOD_NAME = "Vigilant Eureka"; public static final String MOD_ID = "vigilant_eureka"; - public static final String VERSION = "0.0.2-alpha"; - public static final String MOD_KEY = "19d2daed26722f2762d067603604a6d1f909f262"; + static final String VERSION = "0.0.4"; + static final String MOD_KEY = "19d2daed26722f2762d067603604a6d1f909f262"; + static final String DEPENDS = "required-after:baubles@[1.5.2,)"; + public static final Logger LOGGER = LogManager.getLogger(MOD_ID); } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/blocks/BlockLeyLine.java b/src/main/java/me/itstheholyblack/vigilant_eureka/blocks/BlockLeyLine.java index 8039e1e..638fc58 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/blocks/BlockLeyLine.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/blocks/BlockLeyLine.java @@ -3,9 +3,9 @@ import me.itstheholyblack.vigilant_eureka.Reference; import me.itstheholyblack.vigilant_eureka.blocks.tiles.LeyLineTile; import me.itstheholyblack.vigilant_eureka.core.EnumLeyTypes; -import me.itstheholyblack.vigilant_eureka.core.NBTUtil; import me.itstheholyblack.vigilant_eureka.core.PolyHelper; import me.itstheholyblack.vigilant_eureka.items.ModItems; +import me.itstheholyblack.vigilant_eureka.util.NBTUtil; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.ModelResourceLocation; @@ -17,6 +17,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.Style; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.TextFormatting; @@ -29,8 +30,18 @@ import java.util.ArrayList; public class BlockLeyLine extends BlockTileEntity { + + private static final ITextComponent IT_WORKED = new TextComponentTranslation("message.ley_link_good").setStyle(new Style().setColor(TextFormatting.GREEN)); + private static final ITextComponent ALREADY_EXISTS = new TextComponentTranslation("message.ley_link_doublelink").setStyle(new Style().setColor(TextFormatting.RED)); + private static final ITextComponent TWO_WAY = new TextComponentTranslation("message.ley_link_twoway").setStyle(new Style().setColor(TextFormatting.RED)); + private static final ITextComponent SELF_LINK = new TextComponentTranslation("message.ley_link_selflink").setStyle(new Style().setColor(TextFormatting.RED)); + + private static final ITextComponent LEY_SOLVE_GOOD = new TextComponentTranslation("message.ley_solve_good").setStyle(new Style().setColor(TextFormatting.GREEN)); + private static final ITextComponent LEY_SOLVE_INCOMPLETE = new TextComponentTranslation("message.ley_solve_incomplete").setStyle(new Style().setColor(TextFormatting.RED)); + public BlockLeyLine() { super(Material.ROCK, "leyline"); + this.setHardness(Float.POSITIVE_INFINITY); setUnlocalizedName(Reference.MOD_ID + ".leyline"); setRegistryName("leyline"); setCreativeTab(ModItems.CREATIVE_TAB); @@ -45,19 +56,20 @@ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, LeyLineTile tile = this.getTileEntity(worldIn, pos); BlockPos p = net.minecraft.nbt.NBTUtil.getPosFromTag(comp.getCompoundTag("tolink")); LeyLineTile.EnumLinkResults results = tile.addLinkOut(p); - if (results.equals(LeyLineTile.EnumLinkResults.SUCCEED)) { - comp.removeTag("tolink"); - playerIn.sendStatusMessage(new TextComponentTranslation("message.ley_link_good").setStyle(new Style().setColor(TextFormatting.GREEN)), true); - return true; - } else if (results.equals(LeyLineTile.EnumLinkResults.DOUBLELINK)) { - playerIn.sendStatusMessage(new TextComponentTranslation("message.ley_link_doublelink").setStyle(new Style().setColor(TextFormatting.RED)), true); - return false; - } else if (results.equals(LeyLineTile.EnumLinkResults.TWOWAY)) { - playerIn.sendStatusMessage(new TextComponentTranslation("message.ley_link_twoway").setStyle(new Style().setColor(TextFormatting.RED)), true); - return false; - } else { - playerIn.sendStatusMessage(new TextComponentTranslation("message.ley_link_selflink").setStyle(new Style().setColor(TextFormatting.RED)), true); - return false; + switch (results) { + case SUCCEED: + comp.removeTag("tolink"); + playerIn.sendStatusMessage(IT_WORKED, true); + return true; + case DOUBLELINK: + playerIn.sendStatusMessage(ALREADY_EXISTS, true); + return false; + case TWOWAY: + playerIn.sendStatusMessage(TWO_WAY, true); + return false; + case SELFLINK: + playerIn.sendStatusMessage(SELF_LINK, true); + return false; } } else { comp.setTag("tolink", net.minecraft.nbt.NBTUtil.createPosTag(pos)); @@ -71,17 +83,15 @@ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, for (BlockPos p : poly) { LeyLineTile te = (LeyLineTile) worldIn.getTileEntity(p); te.setPolygon(poly); - if (!te.isLead()) { - continue; - } else { + if (te.isLead()) { hasLeader = true; } } thisTile.setLead(!hasLeader); - playerIn.sendStatusMessage(new TextComponentTranslation("message.ley_solve_good").setStyle(new Style().setColor(TextFormatting.GREEN)), true); + playerIn.sendStatusMessage(LEY_SOLVE_GOOD, true); return true; } else { - playerIn.sendStatusMessage(new TextComponentTranslation("message.ley_solve_incomplete").setStyle(new Style().setColor(TextFormatting.RED)), true); + playerIn.sendStatusMessage(LEY_SOLVE_INCOMPLETE, true); return false; } } else if (stack.getItem().equals(ModItems.leyRune)) { diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/blocks/BlockTileEntity.java b/src/main/java/me/itstheholyblack/vigilant_eureka/blocks/BlockTileEntity.java index 466594d..a535af2 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/blocks/BlockTileEntity.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/blocks/BlockTileEntity.java @@ -17,8 +17,14 @@ public BlockTileEntity(Material material, String name) { super(material); } + /** + * Returns the {@link Class} of this block's tile entity + */ public abstract Class getTileEntityClass(); + /** + * Returns the {@link TE} instance for this specific block + */ public TE getTileEntity(IBlockAccess world, BlockPos pos) { return (TE) world.getTileEntity(pos); } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/blocks/MovingCastleDoor.java b/src/main/java/me/itstheholyblack/vigilant_eureka/blocks/MovingCastleDoor.java index 3fa8a48..a4f339a 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/blocks/MovingCastleDoor.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/blocks/MovingCastleDoor.java @@ -87,17 +87,20 @@ public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState s } else { return; } - if (t.getDestination().getY() > 0 && entityIn instanceof EntityPlayer) { - // NBTTagCompound compound = t.getTileData(); - FullPosition destination = t.getDestination(); + FullPosition destination = t.getDestination(); + if (!t.getDestination().equals(BlockPos.ORIGIN)) { if (entityIn.dimension != destination.getDimension()) { - CustomTeleporter.teleportToDimension((EntityPlayer) entityIn, destination.getDimension(), - destination.getX(), destination.getY(), destination.getZ()); + if (entityIn instanceof EntityPlayer) { + CustomTeleporter.teleportToDimension((EntityPlayer) entityIn, destination.getDimension(), + destination.getX(), destination.getY(), destination.getZ()); + } else { + entityIn.setPosition(destination.getX(), destination.getY(), destination.getZ()); + entityIn.changeDimension(destination.getDimension()); + entityIn.setPositionAndUpdate(destination.getX(), destination.getY(), destination.getZ()); + } } else { entityIn.setPositionAndUpdate(destination.getX(), destination.getY(), destination.getZ()); } - } else { - System.out.println(t.getDestination().getY()); } } } @@ -107,6 +110,11 @@ public boolean isNormalCube(IBlockState state, IBlockAccess access, BlockPos pos return false; } + @Override + public boolean isPassable(IBlockAccess worldIn, BlockPos pos) { + return true; + } + @Override public Class getTileEntityClass() { return MovingCastleDoorTile.class; @@ -122,6 +130,11 @@ public boolean isOpaqueCube(IBlockState state) { return false; } + @Override + public boolean isFullCube(IBlockState state) { + return false; + } + public IBlockState getStateFromMeta(int meta) { return getDefaultState().withProperty(IS_TOP, meta == 1); } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/blocks/tiles/LeyLineTile.java b/src/main/java/me/itstheholyblack/vigilant_eureka/blocks/tiles/LeyLineTile.java index 50683b4..19fc2a1 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/blocks/tiles/LeyLineTile.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/blocks/tiles/LeyLineTile.java @@ -1,5 +1,6 @@ package me.itstheholyblack.vigilant_eureka.blocks.tiles; +import me.itstheholyblack.vigilant_eureka.Reference; import me.itstheholyblack.vigilant_eureka.blocks.ModBlocks; import me.itstheholyblack.vigilant_eureka.core.EnumLeyTypes; import me.itstheholyblack.vigilant_eureka.core.Polygon; @@ -13,6 +14,7 @@ import net.minecraft.util.ITickable; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.Style; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.TextFormatting; @@ -26,6 +28,8 @@ public class LeyLineTile extends TileEntity implements ITickable { + private static final ITextComponent ENTER_LEY = new TextComponentTranslation("message.enter_ley").setStyle(new Style().setItalic(true).setColor(TextFormatting.AQUA)); + public float ticks = 0; private BlockPos link_out; @@ -50,16 +54,16 @@ public EnumLinkResults addLinkOut(BlockPos bp) { if (!this.link_out.equals(bp)) { LeyLineTile otherLine = (LeyLineTile) this.world.getTileEntity(bp); if (!otherLine.link_out.equals(this.getPos())) { - System.out.println("Link succeeded!"); + Reference.LOGGER.debug("Link succeeded!"); this.link_out = bp; markDirty(); return EnumLinkResults.SUCCEED; } else { - System.out.println("Link failed - two way connection"); + Reference.LOGGER.debug("Link failed - two way connection"); return EnumLinkResults.TWOWAY; } } else { - System.out.println("Link failed - double linkage"); + Reference.LOGGER.debug("Link failed - double linkage"); return EnumLinkResults.DOUBLELINK; } } @@ -141,15 +145,35 @@ public NBTTagCompound writeToNBT(NBTTagCompound compound) { return compound; } + public boolean isLinked() { + return !this.link_out.equals(BlockPos.ORIGIN) && !this.link_out.equals(BlockPos.ORIGIN.down()); + } + @Override public void update() { ticks = ticks + 0.1F; - if (!this.world.isRemote && !this.link_out.equals(BlockPos.ORIGIN) && this.world.isAreaLoaded(this.getPos(), 16)) { + + if (this.link_out.equals(BlockPos.ORIGIN.down())) { + this.link_out = BlockPos.ORIGIN; + markDirty(); + } + + if (!this.world.isRemote && this.isLinked() && this.world.isAreaLoaded(this.getPos(), 16)) { if (!this.getWorld().getBlockState(link_out).getBlock().equals(ModBlocks.leyLine)) { - link_out = BlockPos.ORIGIN; + link_out = BlockPos.ORIGIN.down(); markDirty(); + return; + } else { + LeyLineTile te = (LeyLineTile) this.world.getTileEntity(link_out); + if (te.getLinkOut().equals(BlockPos.ORIGIN.down())) { + Reference.LOGGER.debug("Linked to BROKEN link node " + this.link_out); + this.link_out = BlockPos.ORIGIN.down(); + markDirty(); + return; + } } } + if (isLead) { delayCounter--; if (delayCounter <= 0 || lastList == null) { @@ -159,11 +183,7 @@ public void update() { for (Entity e : lastList) { NBTTagCompound compound = e.getEntityData(); if (!(compound.getBoolean("inPoly")) && e instanceof EntityPlayer) { - ((EntityPlayer) e).sendStatusMessage(new TextComponentTranslation("message.enter_ley") - .setStyle(new Style() - .setItalic(true) - .setColor(TextFormatting.AQUA) - ), true); + ((EntityPlayer) e).sendStatusMessage(ENTER_LEY, true); } compound.setBoolean("inPoly", specialPoly.contains(e)); compound.setTag("masterPos", NBTUtil.createPosTag(this.pos)); @@ -197,6 +217,7 @@ public SPacketUpdateTileEntity getUpdatePacket() { } @Override + @SideOnly(Side.CLIENT) public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { // Here we get the packet from the server and read it into our client side tile entity this.readFromNBT(packet.getNbtCompound()); @@ -217,7 +238,6 @@ public AxisAlignedBB getRenderBoundingBox() { } public enum EnumLinkResults { - SUCCEED, SELFLINK, DOUBLELINK, TWOWAY; + SUCCEED, SELFLINK, DOUBLELINK, TWOWAY } - } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/client/Icons.java b/src/main/java/me/itstheholyblack/vigilant_eureka/client/Icons.java new file mode 100644 index 0000000..30357e1 --- /dev/null +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/client/Icons.java @@ -0,0 +1,23 @@ +package me.itstheholyblack.vigilant_eureka.client; + +import me.itstheholyblack.vigilant_eureka.client.renderer.RenderHelp; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class Icons { + + public static final Icons INSTANCE = new Icons(); + + public TextureAtlasSprite time_open; + public TextureAtlasSprite time_closed; + + private Icons() { + } + + @SubscribeEvent + public void onTextureStitch(TextureStitchEvent.Pre evt) { + time_open = RenderHelp.forName(evt.getMap(), "time_open_rend", "items"); + time_closed = RenderHelp.forName(evt.getMap(), "time_rend", "items"); + } +} diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/client/Keybinds.java b/src/main/java/me/itstheholyblack/vigilant_eureka/client/Keybinds.java index 591ae7a..6c39a3d 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/client/Keybinds.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/client/Keybinds.java @@ -11,6 +11,7 @@ public class Keybinds { public static KeyBinding warpKey; + public static KeyBinding timeKey; private static KeyBinding init(String s, int key, String group) { KeyBinding kb = new KeyBinding(Reference.MOD_ID + ".keybind." + s, key, group); @@ -20,5 +21,6 @@ private static KeyBinding init(String s, int key, String group) { public static void initWarpKey() { warpKey = init("warp_key", Keyboard.KEY_R, Reference.MOD_ID + ".gui.keybinds"); + timeKey = init("time_key", Keyboard.KEY_G, Reference.MOD_ID + ".gui.keybinds"); } } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/client/LeyLineTileRenderer.java b/src/main/java/me/itstheholyblack/vigilant_eureka/client/LeyLineTileRenderer.java index 123f1d7..69862bc 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/client/LeyLineTileRenderer.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/client/LeyLineTileRenderer.java @@ -32,6 +32,10 @@ public void render(LeyLineTile te, double x, double y, double z, float partialTi int green = 0; if (te.isLead()) { green = 255; + } else if (te.getLinkOut().equals(BlockPos.ORIGIN.down())) { + red = 0; + blue = 255; + green = 0; } else { red = 255; blue = 255; @@ -84,7 +88,8 @@ public void render(LeyLineTile te, double x, double y, double z, float partialTi BlockPos pos = te.getLinkOut(); - if (!pos.equals(BlockPos.ORIGIN)) { + if (!pos.equals(BlockPos.ORIGIN) && !pos.equals(BlockPos.ORIGIN.down())) { + GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE); GlStateManager.disableAlpha(); @@ -93,22 +98,23 @@ public void render(LeyLineTile te, double x, double y, double z, float partialTi bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); - bufferbuilder.pos(0.5, 0.375, 0.5).color(255, 255, 255, 255).endVertex(); - bufferbuilder.pos(0.5, 0.625, 0.5).color(255, 255, 255, 255).endVertex(); + bufferbuilder.pos(0.5, 0.375, 0.5).color(0, 255, 255, 255).endVertex(); + bufferbuilder.pos(0.5, 0.625, 0.5).color(0, 255, 255, 255).endVertex(); bufferbuilder.pos( (pos.getX() - te.getPos().getX()) + 0.5, (pos.getY() - te.getPos().getY()) + 0.375, (pos.getZ() - te.getPos().getZ()) + 0.5) - .color(255, 255, 255, 255).endVertex(); + .color(0, 255, 255, 255).endVertex(); bufferbuilder.pos( (pos.getX() - te.getPos().getX()) + 0.5, (pos.getY() - te.getPos().getY()) + 0.625, (pos.getZ() - te.getPos().getZ()) + 0.5) - .color(255, 255, 255, 255).endVertex(); + .color(0, 255, 255, 255).endVertex(); tessellator.draw(); GlStateManager.popMatrix(); + GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); GlStateManager.enableAlpha(); } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/client/renderer/CustomBipedArmor.java b/src/main/java/me/itstheholyblack/vigilant_eureka/client/renderer/CustomBipedArmor.java index 7a3aea8..b79751d 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/client/renderer/CustomBipedArmor.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/client/renderer/CustomBipedArmor.java @@ -1,10 +1,16 @@ package me.itstheholyblack.vigilant_eureka.client.renderer; import me.itstheholyblack.vigilant_eureka.items.ModItems; +import me.itstheholyblack.vigilant_eureka.util.NBTUtil; import net.minecraft.client.renderer.entity.layers.LayerBipedArmor; import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import javax.annotation.Nonnull; /** * Class to conditionally render armor, allowing full invisibility. Code concept by Paul Fulham, modified by Edwan Vi into a working state. @@ -12,6 +18,7 @@ * @author Paul Fulham * @author Edwan Vi */ +@SideOnly(Side.CLIENT) public class CustomBipedArmor implements LayerRenderer { private LayerBipedArmor layer; @@ -21,8 +28,12 @@ public CustomBipedArmor(LayerBipedArmor l) { } @Override - public void doRenderLayer(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float delta, float age, float yaw, float pitch, float scale) { - if (!entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD).getItem().equals(ModItems.invisCap)) { + public void doRenderLayer(@Nonnull EntityLivingBase entity, float limbSwing, float limbSwingAmount, float delta, float age, float yaw, float pitch, float scale) { + boolean visible = !entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD).getItem().equals(ModItems.invisCap); + if (entity instanceof EntityPlayer) { + visible = visible && !NBTUtil.getPlayerPersist((EntityPlayer) entity).getBoolean("metaphysical_high_ground"); + } + if (visible) { layer.doRenderLayer(entity, limbSwing, limbSwingAmount, delta, age, yaw, pitch, scale); } } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/client/renderer/RenderHelp.java b/src/main/java/me/itstheholyblack/vigilant_eureka/client/renderer/RenderHelp.java new file mode 100644 index 0000000..348ae89 --- /dev/null +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/client/renderer/RenderHelp.java @@ -0,0 +1,99 @@ +package me.itstheholyblack.vigilant_eureka.client.renderer; + +import me.itstheholyblack.vigilant_eureka.Reference; +import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +public class RenderHelp { + + public static TextureAtlasSprite forName(TextureMap ir, String name) { + return ir.registerSprite(new ResourceLocation(Reference.MOD_ID + ":" + name)); + } + + public static TextureAtlasSprite forName(TextureMap ir, String name, String dir) { + return ir.registerSprite(new ResourceLocation(Reference.MOD_ID + ":" + dir + "/" + name)); + } + + + /** + * Renders a sprite from the spritesheet with depth, like a "builtin/generated" item model. + * Adapted from ItemRenderer.renderItemIn2D, 1.7.10 + */ + public static void renderIconIn3D(Tessellator tess, float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, int width, int height, float thickness) { + BufferBuilder wr = tess.getBuffer(); + wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL); + wr.pos(0.0D, 0.0D, 0.0D).tex(p_78439_1_, p_78439_4_).normal(0, 0, 1).endVertex(); + wr.pos(1.0D, 0.0D, 0.0D).tex(p_78439_3_, p_78439_4_).normal(0, 0, 1).endVertex(); + wr.pos(1.0D, 1.0D, 0.0D).tex(p_78439_3_, p_78439_2_).normal(0, 0, 1).endVertex(); + wr.pos(0.0D, 1.0D, 0.0D).tex(p_78439_1_, p_78439_2_).normal(0, 0, 1).endVertex(); + tess.draw(); + wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL); + wr.pos(0.0D, 1.0D, 0.0F - thickness).tex(p_78439_1_, p_78439_2_).normal(0, 0, -1).endVertex(); + wr.pos(1.0D, 1.0D, 0.0F - thickness).tex(p_78439_3_, p_78439_2_).normal(0, 0, -1).endVertex(); + wr.pos(1.0D, 0.0D, 0.0F - thickness).tex(p_78439_3_, p_78439_4_).normal(0, 0, -1).endVertex(); + wr.pos(0.0D, 0.0D, 0.0F - thickness).tex(p_78439_1_, p_78439_4_).normal(0, 0, -1).endVertex(); + tess.draw(); + float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / width; + float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / height; + wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL); + int k; + float f7; + float f8; + + for (k = 0; k < width; ++k) { + f7 = (float) k / (float) width; + f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; + wr.pos(f7, 0.0D, 0.0F - thickness).tex(f8, p_78439_4_).normal(-1, 0, 0).endVertex(); + wr.pos(f7, 0.0D, 0.0D).tex(f8, p_78439_4_).normal(-1, 0, 0).endVertex(); + wr.pos(f7, 1.0D, 0.0D).tex(f8, p_78439_2_).normal(-1, 0, 0).endVertex(); + wr.pos(f7, 1.0D, 0.0F - thickness).tex(f8, p_78439_2_).normal(-1, 0, 0).endVertex(); + } + + tess.draw(); + wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL); + float f9; + + for (k = 0; k < width; ++k) { + f7 = (float) k / (float) width; + f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; + f9 = f7 + 1.0F / width; + wr.pos(f9, 1.0D, 0.0F - thickness).tex(f8, p_78439_2_).normal(1, 0, 0).endVertex(); + wr.pos(f9, 1.0D, 0.0D).tex(f8, p_78439_2_).normal(1, 0, 0).endVertex(); + wr.pos(f9, 0.0D, 0.0D).tex(f8, p_78439_4_).normal(1, 0, 0).endVertex(); + wr.pos(f9, 0.0D, 0.0F - thickness).tex(f8, p_78439_4_).normal(1, 0, 0).endVertex(); + } + + tess.draw(); + wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL); + + for (k = 0; k < height; ++k) { + f7 = (float) k / (float) height; + f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; + f9 = f7 + 1.0F / height; + wr.pos(0.0D, f9, 0.0D).tex(p_78439_1_, f8).normal(0, 1, 0).endVertex(); + wr.pos(1.0D, f9, 0.0D).tex(p_78439_3_, f8).normal(0, 1, 0).endVertex(); + wr.pos(1.0D, f9, 0.0F - thickness).tex(p_78439_3_, f8).normal(0, 1, 0).endVertex(); + wr.pos(0.0D, f9, 0.0F - thickness).tex(p_78439_1_, f8).normal(0, 1, 0).endVertex(); + } + + tess.draw(); + wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL); + + for (k = 0; k < height; ++k) { + f7 = (float) k / (float) height; + f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; + wr.pos(1.0D, f7, 0.0D).tex(p_78439_3_, f8).normal(0, -1, 0).endVertex(); + wr.pos(0.0D, f7, 0.0D).tex(p_78439_1_, f8).normal(0, -1, 0).endVertex(); + wr.pos(0.0D, f7, 0.0F - thickness).tex(p_78439_1_, f8).normal(0, -1, 0).endVertex(); + wr.pos(1.0D, f7, 0.0F - thickness).tex(p_78439_3_, f8).normal(0, -1, 0).endVertex(); + } + + tess.draw(); + + } +} diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/core/ChunkRebuilder.java b/src/main/java/me/itstheholyblack/vigilant_eureka/core/ChunkRebuilder.java new file mode 100644 index 0000000..97bee87 --- /dev/null +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/core/ChunkRebuilder.java @@ -0,0 +1,61 @@ +package me.itstheholyblack.vigilant_eureka.core; + +import me.itstheholyblack.vigilant_eureka.util.ArrayUtil; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.ChunkProviderServer; +import net.minecraft.world.gen.IChunkGenerator; + +public class ChunkRebuilder { + + private static final Block[] blacklist = new Block[]{ + Blocks.END_GATEWAY, + Blocks.END_PORTAL, + Blocks.END_PORTAL_FRAME, + Blocks.BEDROCK, + Blocks.BARRIER, + Blocks.COMMAND_BLOCK, Blocks.CHAIN_COMMAND_BLOCK, Blocks.REPEATING_COMMAND_BLOCK + }; + + public static void rebuildChunk(World world, BlockPos pos, BlockPos stand) { + // ngl i stole this from ICBM + try { + Chunk oldChunk = world.getChunkFromChunkCoords(pos.getX() >> 4, pos.getZ() >> 4); + IChunkProvider provider = world.getChunkProvider(); + IChunkGenerator generator = ((ChunkProviderServer) provider).chunkGenerator; + Chunk newChunk = generator.generateChunk(oldChunk.x, oldChunk.z); + //oldChunk.setTerrainPopulated(false); + //oldChunk.populate(provider, generator); + + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { + for (int y = (pos.getY() - 4); y < (pos.getY() + 4); y++) { + IBlockState state = newChunk.getBlockState(x, y, z); + Block oldBlock = oldChunk.getBlockState(x, y, z).getBlock(); + BlockPos working = new BlockPos(x + oldChunk.x * 16, y, z + oldChunk.z * 16); + if (!ArrayUtil.contains(blacklist, oldBlock)) { + world.setBlockState(working, state, 3); + if (world.canSeeSky(working) && !oldBlock.equals(state.getBlock())) { + ((WorldServer) world).spawnParticle(EnumParticleTypes.ENCHANTMENT_TABLE, true, working.getX(), working.getY(), working.getZ(), 10, 0.5, 1, 0.5, 0.05D); + } + } + } + } + } + oldChunk.setTerrainPopulated(false); + oldChunk.populate(provider, generator); + oldChunk.markDirty(); + oldChunk.resetRelightChecks(); + ((WorldServer) world).spawnParticle(EnumParticleTypes.ENCHANTMENT_TABLE, true, stand.getX(), stand.getY(), stand.getZ(), 1000, 0.75, 1, 0.75, 0.05D); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/core/CustomTeleporter.java b/src/main/java/me/itstheholyblack/vigilant_eureka/core/CustomTeleporter.java index 09168f7..c0a1693 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/core/CustomTeleporter.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/core/CustomTeleporter.java @@ -42,7 +42,7 @@ public void placeInPortal(@Nonnull Entity entity, float rotationYaw) { public static void teleportToDimension(EntityPlayer player, int dimension, double x, double y, double z) { int oldDimension = player.world.provider.getDimension(); EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player; - MinecraftServer server = ((EntityPlayerMP) player).world.getMinecraftServer(); + MinecraftServer server = entityPlayerMP.world.getMinecraftServer(); WorldServer worldServer = server.getWorld(dimension); player.addExperienceLevel(0); diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/core/EventHandler.java b/src/main/java/me/itstheholyblack/vigilant_eureka/core/EventHandler.java index f03e746..d9bbbf6 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/core/EventHandler.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/core/EventHandler.java @@ -5,17 +5,32 @@ import me.itstheholyblack.vigilant_eureka.items.ModItems; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.item.ItemElytra; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTUtil; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import net.minecraft.world.storage.loot.LootEntry; +import net.minecraft.world.storage.loot.LootEntryTable; +import net.minecraft.world.storage.loot.LootPool; +import net.minecraft.world.storage.loot.RandomValueRange; +import net.minecraft.world.storage.loot.conditions.LootCondition; +import net.minecraftforge.event.LootTableLoadEvent; +import net.minecraftforge.event.entity.EntityMountEvent; import net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent; import net.minecraftforge.event.entity.living.LivingEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -27,40 +42,27 @@ public class EventHandler { @SubscribeEvent public void livingTick(LivingEvent.LivingUpdateEvent event) { EntityLivingBase e = event.getEntityLiving(); - if (e.isElytraFlying()) { // OH YES + if (e.isElytraFlying()) { BlockPos pos = e.getPosition(); World worldIn = e.getEntityWorld(); - int i = 0; - while (i <= 9) { - BlockPos scanpos = pos.down(i); - Block scanned = worldIn.getBlockState(scanpos).getBlock(); + for (int i = 0; i < 10; i++) { + Block scanned = worldIn.getBlockState(pos.down(i)).getBlock(); if (scanned.equals(Blocks.FIRE) || scanned.equals(Blocks.LAVA) || scanned.equals(Blocks.FLOWING_LAVA)) { // boost player, using code stolen from Mojang Vec3d vec3d = e.getLookVec(); - double d0 = 1.5D; - double d1 = 0.1D; - e.motionX += vec3d.x * d1 + (vec3d.x * d0 - e.motionX) * 0.2D; - e.motionZ += vec3d.z * d1 + (vec3d.z * d0 - e.motionZ) * 0.2D; - double up_boost; - if (i > 0) { - // A graph of this function is available at https://www.desmos.com/calculator/ss7gkav3cb - // where i is the x axis. - up_boost = -0.07 * i + 0.6; - } else { - up_boost = 0.07; - } - if (up_boost > 0) { - e.addVelocity(0, up_boost, 0); - } + e.motionX += vec3d.x * 0.1 + (vec3d.x * 1.5 - e.motionX) * 0.2D; + e.motionZ += vec3d.z * 0.1 + (vec3d.z * 1.5 - e.motionZ) * 0.2D; + // A graph of this function is available at https://www.desmos.com/calculator/ss7gkav3cb + // where i is the x axis. + e.addVelocity(0, i > 0 ? -0.07 * i + 0.6 : 0.07, 0); break; } else if (!scanned.equals(Blocks.AIR)) { break; } - i++; } } - if (e.getEntityData().getBoolean("inPoly")) { - NBTTagCompound entityData = e.getEntityData(); + NBTTagCompound entityData = e.getEntityData(); + if (entityData.getBoolean("inPoly")) { BlockPos pos = NBTUtil.getPosFromTag(entityData.getCompoundTag("masterPos")); // test if entity still in polygon TileEntity tile = e.getEntityWorld().getTileEntity(pos); @@ -90,18 +92,21 @@ public void livingTick(LivingEvent.LivingUpdateEvent event) { } } } + + if (e instanceof EntityPlayer) { + NBTTagCompound playerData = me.itstheholyblack.vigilant_eureka.util.NBTUtil.getPlayerPersist((EntityPlayer) e); + if (playerData.getBoolean("metaphysical_high_ground")) { + e.setInvisible(true); // simply doing e.setInvisible(playerData.getBoolean("metaphysical_high_ground")) causes invis pots to fail + } + } } @SubscribeEvent public void armorChanged(LivingEquipmentChangeEvent event) { ItemStack oldStack = event.getFrom(); - ItemStack newStack = event.getTo(); EntityEquipmentSlot slot = event.getSlot(); if (slot.equals(EntityEquipmentSlot.HEAD)) { - if (newStack.getItem().equals(ModItems.invisCap)) { - // switch to the invis cap - event.getEntityLiving().setInvisible(true); - } else if (oldStack.getItem().equals(ModItems.invisCap)) { + if (oldStack.getItem().equals(ModItems.invisCap)) { // switch off cap event.getEntityLiving().setInvisible(false); } @@ -115,6 +120,61 @@ public void livingJump(LivingEvent.LivingJumpEvent event) { } } + @SubscribeEvent + public void minecartTakeoff(EntityMountEvent event) { + if (event.isDismounting() && event.getEntityBeingMounted() instanceof EntityMinecart && event.getEntityMounting() instanceof EntityPlayer) { + EntityMinecart minecart = (EntityMinecart) event.getEntityBeingMounted(); + EntityPlayer dismounting = (EntityPlayer) event.getEntityMounting(); + ItemStack chestpiece = dismounting.getItemStackFromSlot(EntityEquipmentSlot.CHEST); + if (chestpiece.getItem().equals(Items.ELYTRA) && ItemElytra.isUsable(chestpiece)) { + if (!event.getWorldObj().isRemote && (Math.abs(minecart.motionX) + Math.abs(minecart.motionY) + Math.abs(minecart.motionZ) != 0)) { + dismounting.addVelocity(minecart.motionX, Math.abs(minecart.motionY) + 5, minecart.motionZ); + EntityPlayerMP player = (EntityPlayerMP) dismounting; + player.setElytraFlying(); + } + } + } + } + + @SubscribeEvent + public void useItem(PlayerInteractEvent event) { + if (!event.getWorld().isRemote) { + EntityPlayerMP player = (EntityPlayerMP) event.getEntityPlayer(); + if (event.getItemStack().getItem().equals(Items.FIREWORKS) && player.isRiding() && player.getRidingEntity() instanceof EntityMinecart) { + if (!player.capabilities.isCreativeMode) { + event.getItemStack().shrink(1); + } + Vec3d v = player.getLookVec(); + player.getRidingEntity().addVelocity(v.x * 500, v.y * 5, v.z * 500); + event.setCancellationResult(EnumActionResult.SUCCESS); + event.setCanceled(true); + } + } + } + + // loot tables + @SubscribeEvent + public void lootLoad(LootTableLoadEvent evt) { + String prefix = "minecraft:chests/"; + String name = evt.getName().toString(); + + if (name.startsWith(prefix)) { + String file = name.substring(name.indexOf(prefix) + prefix.length()); + if (file.equals("stronghold_library") || file.equals("simple_dungeon")) { + Reference.LOGGER.info("Injecting loot..."); + evt.getTable().addPool(getInjectPool("simple_dungeon")); + } + } + } + + private LootPool getInjectPool(String entryName) { + return new LootPool(new LootEntry[]{getInjectEntry(entryName, 1)}, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "eureka_inject_pool"); + } + + private LootEntryTable getInjectEntry(String name, int weight) { + return new LootEntryTable(new ResourceLocation(Reference.MOD_ID, "inject/" + name), weight, 0, new LootCondition[0], "eureka_inject_entry"); + } + private static void removeLeyNBT(EntityLivingBase e) { e.getEntityData().removeTag("timeSince"); e.getEntityData().removeTag("inPoly"); diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/core/InputHandler.java b/src/main/java/me/itstheholyblack/vigilant_eureka/core/InputHandler.java index 200f73d..8e7d04a 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/core/InputHandler.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/core/InputHandler.java @@ -4,7 +4,8 @@ import me.itstheholyblack.vigilant_eureka.client.Keybinds; import me.itstheholyblack.vigilant_eureka.items.ModItems; import me.itstheholyblack.vigilant_eureka.network.PacketHandler; -import me.itstheholyblack.vigilant_eureka.network.PacketSendKey; +import me.itstheholyblack.vigilant_eureka.network.PacketSendTime; +import me.itstheholyblack.vigilant_eureka.network.PacketSendWarp; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.inventory.EntityEquipmentSlot; @@ -18,7 +19,9 @@ public class InputHandler { public void onKeyInput(InputEvent.KeyInputEvent event) { EntityPlayerSP player = Minecraft.getMinecraft().player; if (Keybinds.warpKey.isPressed() && player.getItemStackFromSlot(EntityEquipmentSlot.FEET).getItem().equals(ModItems.warpBoots)) { - PacketHandler.INSTANCE.sendToServer(new PacketSendKey()); + PacketHandler.INSTANCE.sendToServer(new PacketSendWarp()); + } else if (Keybinds.timeKey.isPressed()) { + PacketHandler.INSTANCE.sendToServer(new PacketSendTime()); } } } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/core/NBTUtil.java b/src/main/java/me/itstheholyblack/vigilant_eureka/core/NBTUtil.java deleted file mode 100644 index 833987c..0000000 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/core/NBTUtil.java +++ /dev/null @@ -1,15 +0,0 @@ -package me.itstheholyblack.vigilant_eureka.core; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -public class NBTUtil { - public static NBTTagCompound getTagCompoundSafe(ItemStack stack) { - NBTTagCompound tagCompound = stack.getTagCompound(); - if (tagCompound == null) { - tagCompound = new NBTTagCompound(); - stack.setTagCompound(tagCompound); - } - return tagCompound; - } -} diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/entity/EntityCard.java b/src/main/java/me/itstheholyblack/vigilant_eureka/entity/EntityCard.java new file mode 100644 index 0000000..39f72aa --- /dev/null +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/entity/EntityCard.java @@ -0,0 +1,220 @@ +package me.itstheholyblack.vigilant_eureka.entity; + +import me.itstheholyblack.vigilant_eureka.items.ModItems; +import me.itstheholyblack.vigilant_eureka.util.ArrayUtil; +import me.itstheholyblack.vigilant_eureka.util.FullPosition; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityFallingBlock; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.EnderTeleportEvent; + +import java.util.concurrent.ThreadLocalRandom; + +public class EntityCard extends EntityThrowable { + + private EntityLivingBase thrower; + + public double accelerationX; + public double accelerationY; + public double accelerationZ; + private TYPES type; + + public EntityCard(World world) { + this(world, null, 0, 0, 0); + } + + public EntityCard(World world, EntityLivingBase shooter, double accelX, double accelY, double accelZ) { + super(world); + setSize(0.5F, 0.1F); + this.thrower = shooter; + if (shooter != null) { + this.setLocationAndAngles(shooter.posX, shooter.posY, shooter.posZ, shooter.rotationYaw, shooter.rotationPitch); // sets pos and heading, not motion + this.setPosition(this.posX, this.posY, this.posZ); // possibly redundant, sets position again(?) + } + double d0 = (double) MathHelper.sqrt(accelX * accelX + accelY * accelY + accelZ * accelZ); + this.accelerationX = accelX / d0 * 0.5D; + this.accelerationY = accelY / d0 * 0.5D; + this.accelerationZ = accelZ / d0 * 0.5D; + this.type = TYPES.BLAND; + } + + @Override + public void onUpdate() { + super.onUpdate(); + if (this.ticksExisted >= 20 * 5) { // 20 per second times five seconds, have the compiler do the math + RayTraceResult r = new RayTraceResult( + RayTraceResult.Type.MISS, + new Vec3d(this.posX, this.posY, this.posZ), + EnumFacing.UP, + new BlockPos(this.posX, this.posY, this.posZ) + ); + doImpact(r, false); + } + // update position based on velocity + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + float f = 0.95F; + // update velocity based on accel + this.motionX += this.accelerationX; + this.motionY += this.accelerationY; + this.motionZ += this.accelerationZ; + this.motionX *= (double) f; + this.motionY *= (double) f; + this.motionZ *= (double) f; + // finalize position update + this.setPosition(this.posX, this.posY, this.posZ); + } + + @Override + protected void onImpact(RayTraceResult result) { + if (result.typeOfHit.equals(RayTraceResult.Type.ENTITY)) { + if (!result.entityHit.equals(thrower)) { + // do stuff + if (this.posY >= result.entityHit.getPositionEyes(1).y - 0.4 + && this.posY <= result.entityHit.getPositionEyes(1).y + 0.4) { + doImpact(result, true); + } else { + doImpact(result, false); + } + } + } else { + doImpact(result, false); + } + } + + private void doImpact(RayTraceResult r, boolean amped) { + switch (this.type) { + case BLAND: + if (!this.world.isRemote) { + EntityItem entityItem = new EntityItem(this.world, this.posX, this.posY, this.posZ, new ItemStack(ModItems.itemCard, 1)); + this.world.spawnEntity(entityItem); + } + break; + case EXPLOSION: + this.world.newExplosion(this, this.posX, this.posY, this.posZ, amped ? 3.0F : 1.5F, amped, true); + break; + case ENDERIC: + if (!(this.thrower == null)) { + this.thrower.setPositionAndUpdate(r.hitVec.x, r.hitVec.y + 1, r.hitVec.z); + EnderTeleportEvent enderTeleportEvent = new EnderTeleportEvent( + thrower, + r.hitVec.x, + r.hitVec.y + 1, + r.hitVec.z, + 0.0F); + MinecraftForge.EVENT_BUS.post(enderTeleportEvent); + } + break; + case HOT: + if (r.typeOfHit.equals(RayTraceResult.Type.ENTITY)) { + r.entityHit.setFire(amped ? 8 : 4); + } else { + BlockPos pos = r.getBlockPos(); + this.world.setBlockState(pos.up(), Blocks.FIRE.getDefaultState()); + } + break; + case COLD: + IBlockState cold_things[] = new IBlockState[]{ + Blocks.FROSTED_ICE.getDefaultState(), + Blocks.ICE.getDefaultState(), + Blocks.SNOW.getDefaultState(), + Blocks.PACKED_ICE.getDefaultState() + }; + if (r.typeOfHit.equals(RayTraceResult.Type.BLOCK) && !this.world.isRemote) { + IBlockState state = this.world.getBlockState(this.getPosition()); + if (state.getBlock().equals(Blocks.ICE)) { + this.world.setBlockState(this.getPosition(), Blocks.PACKED_ICE.getDefaultState()); + } else if (state.getBlock().equals(Blocks.WATER)) { + this.world.setBlockState(this.getPosition(), Blocks.ICE.getDefaultState()); + } else { + BlockPos pos = new BlockPos(r.hitVec.addVector(0, 1, 0)); + for (int i = -1; i <= 1; ++i) { + for (int j = -1; j <= 1; ++j) { + for (int d = -1; d <= 1; ++d) { + pos.add(i, j, d); + IBlockState s = ArrayUtil.randomFromArr(cold_things); + // System.out.println(s); + EntitySuspendedIce efb = new EntitySuspendedIce(this.world, pos.getX(), pos.getY(), pos.getZ(), s); + efb.motionX += ((double) i) / ThreadLocalRandom.current().nextDouble(1, 2.5); + efb.motionY += ((double) j) / ThreadLocalRandom.current().nextDouble(1, 2.5); + efb.motionZ += ((double) d) / ThreadLocalRandom.current().nextDouble(1, 2.5); + efb.fallTime = 1; + efb.shouldDropItem = false; + efb.setNoGravity(true); + this.world.spawnEntity(efb); + } + } + } + } + } else if (!this.world.isRemote && r.typeOfHit.equals(RayTraceResult.Type.ENTITY)) { + // entity hit + BlockPos pos = r.entityHit.getPosition(); + EntityFallingBlock efb = new EntityFallingBlock(this.world, pos.getX(), pos.getY() + 1, pos.getZ(), ArrayUtil.randomFromArr(cold_things)); + efb.motionY += 0.75; + efb.fallTime = 1; + efb.setHurtEntities(true); + efb.shouldDropItem = false; + + this.world.spawnEntity(efb); + } + break; + case DIMENSIONAL: + NBTTagCompound nbt = this.getEntityData(); + FullPosition destination = new FullPosition(nbt.getInteger("p_x"), nbt.getInteger("p_y"), nbt.getInteger("p_z"), nbt.getInteger("dim")); + if (!this.world.isRemote && r.entityHit != null) { + if (r.entityHit.dimension != destination.getDimension()) { + r.entityHit.setPosition(destination.getX(), destination.getY(), destination.getZ()); + r.entityHit.changeDimension(destination.getDimension()); + r.entityHit.setPositionAndUpdate(destination.getX(), destination.getY(), destination.getZ()); + } else { + r.entityHit.setPositionAndUpdate(destination.getX(), destination.getY(), destination.getZ()); + } + } + break; + default: + if (!this.world.isRemote) { + EntityItem entityItem = new EntityItem(this.world, this.posX, this.posY, this.posZ, new ItemStack(ModItems.itemCard, 1)); + this.world.spawnEntity(entityItem); + } + break; + } + this.setDead(); + } + + @Override + protected void entityInit() { + } + + @Override + public void readEntityFromNBT(NBTTagCompound compound) { + } + + @Override + public void writeEntityToNBT(NBTTagCompound compound) { + } + + public TYPES getType() { + return type; + } + + public void setType(TYPES type) { + this.type = type; + } + + public enum TYPES { + BLAND, SHARP, COLD, HOT, EXPLOSION, ENDERIC, DIMENSIONAL + } +} diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/entity/EntityPlayerBody.java b/src/main/java/me/itstheholyblack/vigilant_eureka/entity/EntityPlayerBody.java new file mode 100644 index 0000000..b488635 --- /dev/null +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/entity/EntityPlayerBody.java @@ -0,0 +1,161 @@ +package me.itstheholyblack.vigilant_eureka.entity; + +import com.google.common.base.Optional; +import me.itstheholyblack.vigilant_eureka.items.ModItems; +import me.itstheholyblack.vigilant_eureka.util.NBTUtil; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.datasync.DataParameter; +import net.minecraft.network.datasync.DataSerializers; +import net.minecraft.network.datasync.EntityDataManager; +import net.minecraft.potion.PotionEffect; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumHand; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.Style; +import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.World; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.Collection; +import java.util.UUID; + +public class EntityPlayerBody extends EntityLiving { + + private static final DataParameter PLAYER_USERNAME = EntityDataManager.createKey(EntityPlayerBody.class, DataSerializers.STRING); + private static final DataParameter> PLAYER_UUID = EntityDataManager.createKey(EntityPlayerBody.class, DataSerializers.OPTIONAL_UNIQUE_ID); + private static final DataParameter SMALL_ARMS = EntityDataManager.createKey(EntityPlayerBody.class, DataSerializers.BOOLEAN); + private static final ITextComponent INTERACT_MESSAGE = new TextComponentTranslation("message.body").setStyle(new Style().setColor(TextFormatting.GOLD)); + + public EntityPlayerBody(World worldIn) { + super(worldIn); + setSize(1.8F, 0.5F); + setHealth(20); + } + + @Override + public void entityInit() { + super.entityInit(); + dataManager.register(PLAYER_USERNAME, ""); + dataManager.register(SMALL_ARMS, false); + dataManager.register(PLAYER_UUID, Optional.absent()); + } + + @Override + public void writeEntityToNBT(NBTTagCompound compound) { + super.writeEntityToNBT(compound); + compound.setString("playerName", dataManager.get(PLAYER_USERNAME)); + if (dataManager.get(PLAYER_UUID).isPresent()) { + compound.setUniqueId("playerId", dataManager.get(PLAYER_UUID).get()); + } + compound.setBoolean("smallArms", dataManager.get(SMALL_ARMS)); + } + + @Override + public void readEntityFromNBT(NBTTagCompound compound) { + super.readEntityFromNBT(compound); + setPlayerName(compound.getString("playerName")); + setSmallArms(compound.getBoolean("smallArms")); + setPlayerId(compound.getUniqueId("playerId")); + } + + @Override + public void onLivingUpdate() { + super.onLivingUpdate(); + this.limbSwingAmount = 0.0F; + EntityPlayer p = this.world.getPlayerEntityByUUID(this.getPlayerId()); + if (p != null && !world.isRemote) { + // i'm messing with the scoreboard and there's nothing you can do to stop me + if (!this.isOnSameTeam(p)) { + if (this.getTeam() != null) { + world.getScoreboard().removePlayerFromTeam(this.getCachedUniqueIdString(), (ScorePlayerTeam) this.getTeam()); + } + world.getScoreboard().addPlayerToTeam(this.getCachedUniqueIdString(), p.getTeam().getName()); + } + // "sync" potions + Collection playerEffects = p.getActivePotionEffects(); + Collection bodyEffects = this.getActivePotionEffects(); + for (PotionEffect effect : bodyEffects) { + if (!playerEffects.contains(effect)) { + this.removeActivePotionEffect(effect.getPotion()); + this.markPotionsDirty(); + } + } + for (PotionEffect effect : playerEffects) { + if (!this.isPotionActive(effect.getPotion())) { + this.addPotionEffect(effect); + } + } + } + } + + @Override + public boolean processInteract(EntityPlayer player, EnumHand hand) { + if (player.getName().equals(this.getPlayerName())) { + if (!player.getHeldItem(hand).isEmpty() && player.getUniqueID().equals(this.getPlayerId())) { + player.sendStatusMessage(INTERACT_MESSAGE, true); + } else if (player.getUniqueID().equals(this.getPlayerId())) { + this.attackEntityFrom(DamageSource.OUT_OF_WORLD, this.getHealth()); + } + } + return true; + } + + @Override + public boolean attackEntityFrom(@Nonnull DamageSource source, float amount) { + EntityPlayer p = this.world.getPlayerEntityByUUID(this.getPlayerId()); + return (p != null && !source.equals(DamageSource.OUT_OF_WORLD)) ? super.attackEntityFrom(source, amount) && p.attackEntityFrom(source, amount) : super.attackEntityFrom(source, amount); + } + + @Override + public void onDeath(@Nonnull DamageSource cause) { + EntityPlayer p = this.world.getPlayerEntityByUUID(this.getPlayerId()); + if (p != null) { + NBTUtil.getPlayerPersist(p).setBoolean("metaphysical_high_ground", false); + if (!p.getItemStackFromSlot(EntityEquipmentSlot.HEAD).getItem().equals(ModItems.invisCap)) { + p.setInvisible(false); + } + if (!cause.equals(DamageSource.OUT_OF_WORLD)) { + p.attackEntityFrom(cause, p.getHealth()); + } else { + p.setPositionAndUpdate(this.posX, this.posY, this.posZ); + } + } + super.onDeath(cause); + } + + @Nullable + public UUID getPlayerId() { + return dataManager.get(PLAYER_UUID).isPresent() ? dataManager.get(PLAYER_UUID).get() : null; + } + + public void setPlayerId(UUID id) { + dataManager.set(PLAYER_UUID, Optional.of(id)); + } + + public String getPlayerName() { + return dataManager.get(PLAYER_USERNAME); + } + + public void setPlayerName(String name) { + if (name.endsWith("s")) { + this.setCustomNameTag(name + "' body"); + } else { + this.setCustomNameTag(name + "'s body"); + } + dataManager.set(PLAYER_USERNAME, name); + } + + public boolean smallArms() { + return dataManager.get(SMALL_ARMS); + } + + public void setSmallArms(boolean smallArms) { + dataManager.set(SMALL_ARMS, smallArms); + } +} diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/entity/EntitySuspendedIce.java b/src/main/java/me/itstheholyblack/vigilant_eureka/entity/EntitySuspendedIce.java new file mode 100644 index 0000000..6813a8a --- /dev/null +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/entity/EntitySuspendedIce.java @@ -0,0 +1,75 @@ +package me.itstheholyblack.vigilant_eureka.entity; + +import io.netty.buffer.ByteBuf; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.item.EntityFallingBlock; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; + +public class EntitySuspendedIce extends EntityFallingBlock implements IEntityAdditionalSpawnData { + + private IBlockState fallTile; + + public EntitySuspendedIce(World worldIn) { + super(worldIn, 0, 0, 0, Blocks.FROSTED_ICE.getDefaultState()); + } + + public EntitySuspendedIce(World worldIn, double x, double y, double z, IBlockState fallingBlockState) { + super(worldIn, x, y, z, fallingBlockState); + this.fallTile = fallingBlockState; + } + + @Override + public void onUpdate() { + super.onUpdate(); + if (this.ticksExisted > 20) { + this.setNoGravity(false); + this.addVelocity(0, -0.5, 0); + this.setHurtEntities(true); + } + } + + + @Override + public void writeSpawnData(ByteBuf buffer) { + int state = 0; + try { + if (this.fallTile.equals(Blocks.ICE.getDefaultState())) { + buffer.writeInt(state); + return; + } else if (this.fallTile.equals(Blocks.FROSTED_ICE.getDefaultState())) { + state = 1; + } else if (this.fallTile.equals(Blocks.PACKED_ICE)) { + state = 2; + } else if (this.fallTile.equals(Blocks.SNOW.getDefaultState())) { + state = 3; + } + } catch (NullPointerException e) { + state = 3; + } + buffer.writeInt(state); + } + + @Override + public void readSpawnData(ByteBuf additionalData) { + int state = additionalData.readInt(); + switch (state) { + case 0: + this.fallTile = Blocks.ICE.getDefaultState(); + break; + case 1: + this.fallTile = Blocks.FROSTED_ICE.getDefaultState(); + break; + case 2: + this.fallTile = Blocks.PACKED_ICE.getDefaultState(); + break; + case 3: + this.fallTile = Blocks.SNOW.getDefaultState(); + break; + default: + this.fallTile = Blocks.FROSTED_ICE.getDefaultState(); + break; + } + } +} diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/entity/ModEntities.java b/src/main/java/me/itstheholyblack/vigilant_eureka/entity/ModEntities.java new file mode 100644 index 0000000..3a34579 --- /dev/null +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/entity/ModEntities.java @@ -0,0 +1,26 @@ +package me.itstheholyblack.vigilant_eureka.entity; + +import me.itstheholyblack.vigilant_eureka.Eureka; +import me.itstheholyblack.vigilant_eureka.Reference; +import me.itstheholyblack.vigilant_eureka.entity.render.RenderEntityCard; +import me.itstheholyblack.vigilant_eureka.entity.render.RenderEntityPlayerBody; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.client.registry.RenderingRegistry; +import net.minecraftforge.fml.common.registry.EntityRegistry; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public class ModEntities { + public static void init() { + int id = 1; + EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "thrown_card"), EntityCard.class, Reference.MOD_ID + ":thrown_card", id++, Eureka.instance, 64, 1, true); + EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "suspended_ice"), EntitySuspendedIce.class, Reference.MOD_ID + ":suspended_ice", id++, Eureka.instance, 64, 1, true); + EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "player_body"), EntityPlayerBody.class, Reference.MOD_ID + ":player_body", id++, Eureka.instance, 64, 1, true); + } + + @SideOnly(Side.CLIENT) + public static void initModels() { + RenderingRegistry.registerEntityRenderingHandler(EntityCard.class, RenderEntityCard.FACTORY); + RenderingRegistry.registerEntityRenderingHandler(EntityPlayerBody.class, RenderEntityPlayerBody::new); + } +} diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/entity/render/RenderEntityCard.java b/src/main/java/me/itstheholyblack/vigilant_eureka/entity/render/RenderEntityCard.java new file mode 100644 index 0000000..4695feb --- /dev/null +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/entity/render/RenderEntityCard.java @@ -0,0 +1,53 @@ +package me.itstheholyblack.vigilant_eureka.entity.render; + +import me.itstheholyblack.vigilant_eureka.entity.EntityCard; +import me.itstheholyblack.vigilant_eureka.items.ModItems; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.RenderItem; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderEntity; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.client.registry.IRenderFactory; + +public class RenderEntityCard extends RenderEntity { + public static final Factory FACTORY = new Factory(); + private RenderItem itemRenderer; + + public RenderEntityCard(RenderManager renderManagerIn) { + super(renderManagerIn); + } + + @Override + public void doRender(Entity entity, double x, double y, double z, float entityYaw, float partialTicks) { + if (this.itemRenderer == null) { + this.itemRenderer = Minecraft.getMinecraft().getRenderItem(); + } + GlStateManager.pushMatrix(); + GlStateManager.translate((float) x, (float) y, (float) z); + GlStateManager.disableLighting(); + GlStateManager.rotate(0, 1.0F, 0.0F, 0.0F); + GlStateManager.rotate(entity.rotationPitch, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(entity.rotationYaw, 0, 0, 1); + GlStateManager.pushAttrib(); + RenderHelper.enableStandardItemLighting(); + + this.itemRenderer.renderItem(new ItemStack(ModItems.itemCard, 1), ItemCameraTransforms.TransformType.FIXED); + + RenderHelper.disableStandardItemLighting(); + GlStateManager.popAttrib(); + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); + } + + public static class Factory implements IRenderFactory { + @Override + public Render createRenderFor(RenderManager manager) { + return new RenderEntityCard(manager); + } + } +} diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/entity/render/RenderEntityPlayerBody.java b/src/main/java/me/itstheholyblack/vigilant_eureka/entity/render/RenderEntityPlayerBody.java new file mode 100644 index 0000000..060f793 --- /dev/null +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/entity/render/RenderEntityPlayerBody.java @@ -0,0 +1,52 @@ +package me.itstheholyblack.vigilant_eureka.entity.render; + +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import me.itstheholyblack.vigilant_eureka.entity.EntityPlayerBody; +import net.minecraft.client.Minecraft; +import net.minecraft.client.model.ModelPlayer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.entity.RenderBiped; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.resources.DefaultPlayerSkin; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; + +import javax.annotation.Nonnull; +import java.util.Map; +import java.util.UUID; + +public class RenderEntityPlayerBody extends RenderBiped { + + public RenderEntityPlayerBody(RenderManager renderManagerIn) { + super(renderManagerIn, new ModelPlayer(0.0F, false), 0); + } + + @Override + public void doRender(@Nonnull EntityPlayerBody dopple, double x, double y, double z, float yaw, float partialTicks) { + this.mainModel = new ModelPlayer(0.0f, dopple.smallArms()); + super.doRender(dopple, x, y, z, yaw, partialTicks); + } + + @Override + protected void applyRotations(EntityPlayerBody entityLiving, float p_77043_2_, float rotationYaw, float partialTicks) { + GlStateManager.rotate(180.0F - rotationYaw, 0, 1, 0); + GlStateManager.translate(0, 0, -1); + GlStateManager.translate(0, 0.24, 0); + GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); + } + + @Nonnull + @Override + protected ResourceLocation getEntityTexture(@Nonnull EntityPlayerBody entity) { + GameProfile profile = new GameProfile(entity.getPlayerId(), entity.getPlayerName()); + Minecraft minecraft = Minecraft.getMinecraft(); + Map map = minecraft.getSkinManager().loadSkinFromCache(profile); + if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) { + return minecraft.getSkinManager().loadSkin(map.get(MinecraftProfileTexture.Type.SKIN), MinecraftProfileTexture.Type.SKIN); + } else { + UUID uuid = EntityPlayer.getUUID(profile); + return DefaultPlayerSkin.getDefaultSkin(uuid); + } + } +} diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/items/DebugStick.java b/src/main/java/me/itstheholyblack/vigilant_eureka/items/DebugStick.java index c307e41..67f04a6 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/items/DebugStick.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/items/DebugStick.java @@ -1,20 +1,19 @@ package me.itstheholyblack.vigilant_eureka.items; import me.itstheholyblack.vigilant_eureka.Reference; +import me.itstheholyblack.vigilant_eureka.network.PacketHandler; +import me.itstheholyblack.vigilant_eureka.network.PacketSpawnBody; +import me.itstheholyblack.vigilant_eureka.util.NBTUtil; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraft.world.WorldServer; -import net.minecraft.world.gen.structure.template.PlacementSettings; -import net.minecraft.world.gen.structure.template.Template; -import net.minecraft.world.gen.structure.template.TemplateManager; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -32,12 +31,15 @@ public void initModel() { @Override public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - if (!worldIn.isRemote) { - WorldServer server = (WorldServer) worldIn; - TemplateManager templateManager = server.getStructureTemplateManager(); - Template template = templateManager.get(null, new ResourceLocation(Reference.MOD_ID + ":leystruct1")); - template.addBlocksToWorld(worldIn, pos, new PlacementSettings()); + NBTTagCompound persist = NBTUtil.getPlayerPersist(playerIn); + if (!persist.getBoolean("metaphysical_high_ground")) { + persist.setBoolean("metaphysical_high_ground", true); + playerIn.setInvisible(true); + if (worldIn.isRemote) { + PacketHandler.INSTANCE.sendToServer(new PacketSpawnBody()); + } + return EnumActionResult.SUCCESS; } - return EnumActionResult.SUCCESS; + return EnumActionResult.FAIL; } } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/items/DimKey.java b/src/main/java/me/itstheholyblack/vigilant_eureka/items/DimKey.java index 3cf9465..343b0d3 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/items/DimKey.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/items/DimKey.java @@ -4,7 +4,7 @@ import me.itstheholyblack.vigilant_eureka.blocks.ModBlocks; import me.itstheholyblack.vigilant_eureka.blocks.MovingCastleDoor; import me.itstheholyblack.vigilant_eureka.blocks.tiles.MovingCastleDoorTile; -import me.itstheholyblack.vigilant_eureka.core.NBTUtil; +import me.itstheholyblack.vigilant_eureka.util.NBTUtil; import me.itstheholyblack.vigilant_eureka.util.RayTraceHelper; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelBakery; @@ -20,8 +20,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.*; import net.minecraft.world.DimensionType; import net.minecraft.world.World; import net.minecraftforge.client.model.ModelLoader; @@ -33,6 +32,9 @@ public class DimKey extends Item { + private static final ITextComponent DOOR_SUCCESS_MESSAGE = new TextComponentTranslation("message.door_set_success").setStyle(new Style().setColor(TextFormatting.GREEN)); + private static final ITextComponent DOOR_FAIL_MESSAGE = new TextComponentTranslation("message.door_set_fail").setStyle(new Style().setColor(TextFormatting.RED)); + public DimKey() { setRegistryName(Reference.MOD_ID, "dim_key"); setUnlocalizedName(Reference.MOD_ID + ".dim_key"); @@ -73,34 +75,24 @@ public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos System.out.println(worldIn.getBlockState(pos).getBlock()); if (worldIn.getBlockState(pos).getBlock().equals(ModBlocks.movingdoor)) { - System.out.println("clicked on door"); - MovingCastleDoorTile t; - if (worldIn.getBlockState(pos).getValue(MovingCastleDoor.IS_TOP)) { - t = (MovingCastleDoorTile) worldIn.getTileEntity(pos); - } else { - t = (MovingCastleDoorTile) worldIn.getTileEntity(pos.up()); - } - if (tag != null && t != null && tag.getInteger("y") > 0) { + MovingCastleDoorTile t = worldIn.getBlockState(pos).getValue(MovingCastleDoor.IS_TOP) ? + (MovingCastleDoorTile) worldIn.getTileEntity(pos) : + (MovingCastleDoorTile) worldIn.getTileEntity(pos.up()); + if (t != null && tag.getInteger("y") > 0) { t.setDestination( new BlockPos(tag.getInteger("x"), tag.getInteger("y"), tag.getInteger("z")), - stack.getTagCompound().getInteger("dim")); - playerIn.sendStatusMessage(new TextComponentString(TextFormatting.GREEN + "Click."), true); + tag.getInteger("dim")); + playerIn.sendStatusMessage(DOOR_SUCCESS_MESSAGE, true); return EnumActionResult.SUCCESS; } else if (tag.getInteger("y") <= 0) { - playerIn.sendStatusMessage(new TextComponentString(TextFormatting.RED + "It won't turn."), true); + playerIn.sendStatusMessage(DOOR_FAIL_MESSAGE, true); return EnumActionResult.FAIL; } } - - System.out.println("Did not click door, was " + worldIn.getBlockState(pos).getBlock() + " instead."); - int x = playerIn.getPosition().getX(); - int y = playerIn.getPosition().getY(); - int z = playerIn.getPosition().getZ(); - int dim = playerIn.dimension; - tag.setInteger("x", x); - tag.setInteger("y", y); - tag.setInteger("z", z); - tag.setInteger("dim", dim); + tag.setInteger("x", playerIn.getPosition().getX()); + tag.setInteger("y", playerIn.getPosition().getY()); + tag.setInteger("z", playerIn.getPosition().getZ()); + tag.setInteger("dim", playerIn.dimension); return EnumActionResult.SUCCESS; } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/items/ItemCard.java b/src/main/java/me/itstheholyblack/vigilant_eureka/items/ItemCard.java new file mode 100644 index 0000000..8d08439 --- /dev/null +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/items/ItemCard.java @@ -0,0 +1,115 @@ +package me.itstheholyblack.vigilant_eureka.items; + +import me.itstheholyblack.vigilant_eureka.Reference; +import me.itstheholyblack.vigilant_eureka.entity.EntityCard; +import me.itstheholyblack.vigilant_eureka.util.NBTUtil; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; +import net.minecraft.world.World; +import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import java.util.HashMap; +import java.util.List; + +public class ItemCard extends Item { + private static HashMap TYPE_MAP = new HashMap<>(); + + public ItemCard() { + setRegistryName(Reference.MOD_ID, "throwing_card"); + setUnlocalizedName(Reference.MOD_ID + ".throwing_card"); + setMaxStackSize(128); + setCreativeTab(ModItems.CREATIVE_TAB); + + for (Item i : new Item[]{Items.SNOWBALL, Item.getItemFromBlock(Blocks.SNOW), Item.getItemFromBlock(Blocks.SNOW_LAYER), Item.getItemFromBlock(Blocks.ICE), Item.getItemFromBlock(Blocks.PACKED_ICE)}) { + TYPE_MAP.put(i, EntityCard.TYPES.COLD); + } + + for (Item i : new Item[]{Items.TNT_MINECART, Items.FIREWORKS, Items.FIREWORK_CHARGE, Item.getItemFromBlock(Blocks.TNT)}) { + TYPE_MAP.put(i, EntityCard.TYPES.EXPLOSION); + } + + for (Item i : new Item[]{Items.BLAZE_ROD, Items.BLAZE_POWDER, Items.FIRE_CHARGE, Items.FLINT_AND_STEEL}) { + TYPE_MAP.put(i, EntityCard.TYPES.HOT); + } + + for (Item i : new Item[]{ + Items.ENDER_EYE, + Items.ENDER_PEARL, + Items.END_CRYSTAL, + Item.getItemFromBlock(Blocks.END_STONE), + Item.getItemFromBlock(Blocks.END_BRICKS), + Item.getItemFromBlock(Blocks.END_ROD), + Item.getItemFromBlock(Blocks.ENDER_CHEST), + Item.getItemFromBlock(Blocks.PURPUR_BLOCK), Item.getItemFromBlock(Blocks.PURPUR_SLAB), Item.getItemFromBlock(Blocks.PURPUR_PILLAR), Item.getItemFromBlock(Blocks.PURPUR_STAIRS), + Items.CHORUS_FRUIT, + Items.CHORUS_FRUIT_POPPED, + Item.getItemFromBlock(Blocks.CHORUS_FLOWER), Item.getItemFromBlock(Blocks.CHORUS_PLANT) + }) { + TYPE_MAP.put(i, EntityCard.TYPES.ENDERIC); + } + } + + public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { + ItemStack itemstack = playerIn.getHeldItem(handIn); + if (!playerIn.capabilities.isCreativeMode) { + itemstack.shrink(1); + } + if (!worldIn.isRemote) { + EntityCard c = new EntityCard(worldIn, playerIn, playerIn.getLook(1).x, playerIn.getLook(1).y, playerIn.getLook(1).z); + c.setType(EntityCard.TYPES.BLAND); + c.posY += playerIn.getEyeHeight(); + c.setPositionAndRotation(c.posX, c.posY, c.posZ, playerIn.cameraYaw, playerIn.cameraPitch); + worldIn.spawnEntity(c); + + ItemStack other; + if (handIn.equals(EnumHand.MAIN_HAND)) { + other = playerIn.getHeldItem(EnumHand.OFF_HAND); + } else { + other = playerIn.getHeldItem(EnumHand.MAIN_HAND); + } + + Item otherItem = other.getItem(); + c.setType(getTypeFromItem(otherItem)); + if (otherItem.equals(ModItems.dimKey)) { + NBTTagCompound keyComp = NBTUtil.getTagCompoundSafe(other); + NBTTagCompound cardComp = c.getEntityData(); + cardComp.setInteger("p_x", keyComp.getInteger("x")); + cardComp.setInteger("p_y", keyComp.getInteger("y")); + cardComp.setInteger("p_z", keyComp.getInteger("z")); + cardComp.setInteger("dim", keyComp.getInteger("dim")); + } else if (otherItem instanceof ItemSword) { + c.setType(EntityCard.TYPES.SHARP); + } + return new ActionResult<>(EnumActionResult.SUCCESS, itemstack); + } + return new ActionResult<>(EnumActionResult.SUCCESS, itemstack); + } + + private static EntityCard.TYPES getTypeFromItem(Item item) { + return TYPE_MAP.get(item) == null ? EntityCard.TYPES.BLAND : TYPE_MAP.get(item); + } + + @SideOnly(Side.CLIENT) + public void initModel() { + ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory")); + } + + @SideOnly(Side.CLIENT) + @Override + public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { + tooltip.add(I18n.format("mouseovertext.throwing_card")); + } +} diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/items/ItemLeyKey.java b/src/main/java/me/itstheholyblack/vigilant_eureka/items/ItemLeyKey.java index b536acd..ceca95d 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/items/ItemLeyKey.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/items/ItemLeyKey.java @@ -1,12 +1,17 @@ package me.itstheholyblack.vigilant_eureka.items; import me.itstheholyblack.vigilant_eureka.Reference; +import me.itstheholyblack.vigilant_eureka.util.NBTUtil; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.client.model.ModelLoader; @@ -23,29 +28,31 @@ public ItemLeyKey() { setCreativeTab(ModItems.CREATIVE_TAB); } + public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { + ItemStack stack = playerIn.getHeldItem(handIn); + if (playerIn.isSneaking()) { + NBTUtil.getTagCompoundSafe(stack).removeTag("tolink"); + } + return new ActionResult<>(EnumActionResult.SUCCESS, stack); + } + @SideOnly(Side.CLIENT) @Override public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { - NBTTagCompound compound = stack.getTagCompound(); - if (compound != null) { - BlockPos p = net.minecraft.nbt.NBTUtil.getPosFromTag(compound.getCompoundTag("tolink")); - int x; - int y; - int z; - x = p.getX(); - y = p.getY(); - z = p.getZ(); - // (0, 0, 0) isn't reachable without breaking bedrock - if (y == 0) { - tooltip.add(I18n.format("mouseovertext.ley_key")); - } else { - String fulltip = I18n.format("mouseovertext.ley_key") + "\nX: " + Integer.toString(x) + "\nY: " - + Integer.toString(y) + "\nZ: " + Integer.toString(z); - tooltip.add(fulltip); - } - } else { + NBTTagCompound compound = NBTUtil.getTagCompoundSafe(stack); + BlockPos p = net.minecraft.nbt.NBTUtil.getPosFromTag(compound.getCompoundTag("tolink")); + int x = p.getX(); + int y = p.getY(); + int z = p.getZ(); + // (0, 0, 0) isn't reachable without breaking bedrock + if (y == 0) { tooltip.add(I18n.format("mouseovertext.ley_key")); + } else { + String fulltip = I18n.format("mouseovertext.ley_key") + "\nX: " + Integer.toString(x) + "\nY: " + + Integer.toString(y) + "\nZ: " + Integer.toString(z); + tooltip.add(fulltip); } + super.addInformation(stack, worldIn, tooltip, flagIn); } @@ -56,6 +63,6 @@ public void initModel() { @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack stack) { - return me.itstheholyblack.vigilant_eureka.core.NBTUtil.getTagCompoundSafe(stack).hasKey("tolink"); + return NBTUtil.getTagCompoundSafe(stack).hasKey("tolink"); } } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/items/ItemLeyRune.java b/src/main/java/me/itstheholyblack/vigilant_eureka/items/ItemLeyRune.java index 8da72fc..84688a1 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/items/ItemLeyRune.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/items/ItemLeyRune.java @@ -2,7 +2,7 @@ import me.itstheholyblack.vigilant_eureka.Reference; import me.itstheholyblack.vigilant_eureka.core.EnumLeyTypes; -import me.itstheholyblack.vigilant_eureka.core.NBTUtil; +import me.itstheholyblack.vigilant_eureka.util.NBTUtil; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/items/ModItems.java b/src/main/java/me/itstheholyblack/vigilant_eureka/items/ModItems.java index 769e1c0..0e86a1b 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/items/ModItems.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/items/ModItems.java @@ -3,6 +3,7 @@ import me.itstheholyblack.vigilant_eureka.Reference; import me.itstheholyblack.vigilant_eureka.items.armor.InvisCap; import me.itstheholyblack.vigilant_eureka.items.armor.WarpBoots; +import me.itstheholyblack.vigilant_eureka.items.baubles.ItemTime; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.registry.GameRegistry; @@ -24,6 +25,10 @@ public class ModItems { public static ItemLeyRune leyRune; @GameRegistry.ObjectHolder(Reference.MOD_ID + ":debug_stick") public static DebugStick debugStick; + @GameRegistry.ObjectHolder(Reference.MOD_ID + ":throwing_card") + public static ItemCard itemCard; + @GameRegistry.ObjectHolder(Reference.MOD_ID + ":time") + public static ItemTime itemTime; public static final CreativeTabs CREATIVE_TAB = new CreativeTabs("vigilantEureka") { @Override @@ -37,8 +42,10 @@ public static void initModels() { dimKey.initModel(); warpBoots.initModel(); invisCap.initModel(); + itemTime.initModel(); bismite.initModel(); leyKey.initModel(); debugStick.initModel(); + itemCard.initModel(); } } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/items/armor/ArmorTypes.java b/src/main/java/me/itstheholyblack/vigilant_eureka/items/armor/ArmorTypes.java index d765318..fc34df7 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/items/armor/ArmorTypes.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/items/armor/ArmorTypes.java @@ -5,8 +5,8 @@ import net.minecraft.item.ItemArmor; import net.minecraftforge.common.util.EnumHelper; -public class ArmorTypes { - public static final ItemArmor.ArmorMaterial BUGGER_ME_MAT = EnumHelper.addArmorMaterial("BUGGER_ME_MAT", +class ArmorTypes { + static final ItemArmor.ArmorMaterial BUGGER_ME_MAT = EnumHelper.addArmorMaterial("BUGGER_ME_MAT", Reference.MOD_ID + ":bugger_me", 20, new int[]{2, 6, 5, 2}, 40, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0.0F); } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/items/armor/InvisCap.java b/src/main/java/me/itstheholyblack/vigilant_eureka/items/armor/InvisCap.java index d87a36b..76fe01e 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/items/armor/InvisCap.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/items/armor/InvisCap.java @@ -5,6 +5,7 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; @@ -33,4 +34,9 @@ public void initModel() { public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { tooltip.add(I18n.format("mouseovertext.invis_cap")); } + + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { + player.setInvisible(true); + } } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/items/baubles/ItemTime.java b/src/main/java/me/itstheholyblack/vigilant_eureka/items/baubles/ItemTime.java new file mode 100644 index 0000000..fc20da7 --- /dev/null +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/items/baubles/ItemTime.java @@ -0,0 +1,97 @@ +package me.itstheholyblack.vigilant_eureka.items.baubles; + +import baubles.api.BaubleType; +import baubles.api.IBauble; +import baubles.api.render.IRenderBauble; +import me.itstheholyblack.vigilant_eureka.Reference; +import me.itstheholyblack.vigilant_eureka.client.Icons; +import me.itstheholyblack.vigilant_eureka.client.renderer.RenderHelp; +import me.itstheholyblack.vigilant_eureka.items.ModItems; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.item.IItemPropertyGetter; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import javax.annotation.Nullable; +import java.util.List; + +public class ItemTime extends Item implements IBauble, IRenderBauble { + public ItemTime() { + // set property for multitexture + this.addPropertyOverride(new ResourceLocation("open_eye"), new IItemPropertyGetter() { + @Override + @SideOnly(Side.CLIENT) + public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) { + if (entityIn instanceof EntityPlayer && ((EntityPlayer) entityIn).getCooldownTracker().hasCooldown(stack.getItem())) { + return 1.0F; + } + return 0.0F; + } + }); + setRegistryName(Reference.MOD_ID, "time"); + setUnlocalizedName(Reference.MOD_ID + ".time"); + this.setMaxStackSize(1); + this.setCreativeTab(ModItems.CREATIVE_TAB); + } + + @SideOnly(Side.CLIENT) + public void initModel() { + ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory")); + } + + @Override + public BaubleType getBaubleType(ItemStack itemStack) { + return BaubleType.AMULET; + } + + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack itemStack, EntityPlayer entityPlayer, RenderType renderType, float v) { + if (renderType.equals(RenderType.BODY)) { + if (!entityPlayer.isInvisible()) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + Helper.rotateIfSneaking(entityPlayer); + Helper.translateToChest(); + Helper.defaultTransforms(); + scale(1.25F); + boolean armor = !(entityPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty() || entityPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem().equals(Items.ELYTRA)); + GlStateManager.translate(-0.5F, -0.7F, armor ? 0.1F : 0F); + + boolean open = entityPlayer.getCooldownTracker().hasCooldown(this); + TextureAtlasSprite gemIcon = open ? Icons.INSTANCE.time_open : Icons.INSTANCE.time_closed; + float f = gemIcon.getMinU(); + float f1 = gemIcon.getMaxU(); + float f2 = gemIcon.getMinV(); + float f3 = gemIcon.getMaxV(); + RenderHelp.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); + } + } + } + + @SideOnly(Side.CLIENT) + @Override + public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { + tooltip.add(I18n.format("mouseovertext.time")); + } + + @SideOnly(Side.CLIENT) + private static void scale(float f) { + GlStateManager.scale(f, f, f); + } +} diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/network/PacketHandler.java b/src/main/java/me/itstheholyblack/vigilant_eureka/network/PacketHandler.java index f8c24ef..44d50b0 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/network/PacketHandler.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/network/PacketHandler.java @@ -12,7 +12,7 @@ public class PacketHandler { public PacketHandler() { } - public static int nextID() { + private static int nextID() { return packetId++; } @@ -22,8 +22,10 @@ public static void registerMessages(String channelName) { } public static void registerMessages() { - // Register messages which are sent from the client to the server here: - INSTANCE.registerMessage(PacketSendKey.Handler.class, PacketSendKey.class, nextID(), Side.SERVER); + INSTANCE.registerMessage(PacketSendWarp.Handler.class, PacketSendWarp.class, nextID(), Side.SERVER); + INSTANCE.registerMessage(PacketSendTime.Handler.class, PacketSendTime.class, nextID(), Side.SERVER); + INSTANCE.registerMessage(PacketSpawnBody.Handler.class, PacketSpawnBody.class, nextID(), Side.SERVER); + INSTANCE.registerMessage(PacketEndericPoof.Handler.class, PacketEndericPoof.class, nextID(), Side.CLIENT); } } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/network/PacketSendTime.java b/src/main/java/me/itstheholyblack/vigilant_eureka/network/PacketSendTime.java new file mode 100644 index 0000000..51423c8 --- /dev/null +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/network/PacketSendTime.java @@ -0,0 +1,75 @@ +package me.itstheholyblack.vigilant_eureka.network; + +import baubles.api.BaublesApi; +import io.netty.buffer.ByteBuf; +import me.itstheholyblack.vigilant_eureka.core.ChunkRebuilder; +import me.itstheholyblack.vigilant_eureka.items.ModItems; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.network.simpleimpl.IMessage; +import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; +import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public class PacketSendTime implements IMessage { + + private BlockPos look; + private BlockPos stand; + + private static final ITextComponent EYE_ALREADY_OPEN = new TextComponentTranslation("message.eye_already_open"); + + @Override + public void fromBytes(ByteBuf buf) { + // Encoding the position as a long is more efficient + look = BlockPos.fromLong(buf.readLong()); + stand = BlockPos.fromLong(buf.readLong()); + } + + @Override + public void toBytes(ByteBuf buf) { + // Encoding the position as a long is more efficient + buf.writeLong(look.toLong()); + buf.writeLong(stand.toLong()); + } + + + @SideOnly(Side.CLIENT) + public PacketSendTime() { + RayTraceResult result = Minecraft.getMinecraft().objectMouseOver; + look = result.getBlockPos(); + stand = Minecraft.getMinecraft().player.getPosition(); + } + + public static class Handler implements IMessageHandler { + @Override + public IMessage onMessage(PacketSendTime message, MessageContext ctx) { + // Always use a construct like this to actually handle your message. This ensures that + // your 'handle' code is run on the main Minecraft thread. 'onMessage' itself + // is called on the networking thread so it is not safe to do a lot of things + // here. + FMLCommonHandler.instance().getWorldThread(ctx.netHandler).addScheduledTask(() -> handle(message, ctx)); + return null; + } + + private void handle(PacketSendTime message, MessageContext ctx) { + // This code is run on the server side. So you can do server-side calculations here + EntityPlayerMP playerEntity = ctx.getServerHandler().player; + World world = playerEntity.getEntityWorld(); + BlockPos pos = message.look; + if (!playerEntity.getCooldownTracker().hasCooldown(ModItems.itemTime) && BaublesApi.isBaubleEquipped(playerEntity, ModItems.itemTime) != -1 && !world.isRemote && world instanceof WorldServer) { + playerEntity.getCooldownTracker().setCooldown(ModItems.itemTime, 100); + ChunkRebuilder.rebuildChunk(world, pos, message.stand); + } else if (playerEntity.getCooldownTracker().hasCooldown(ModItems.itemTime)) { + playerEntity.sendStatusMessage(EYE_ALREADY_OPEN, true); + } + } + } +} diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/network/PacketSendKey.java b/src/main/java/me/itstheholyblack/vigilant_eureka/network/PacketSendWarp.java similarity index 87% rename from src/main/java/me/itstheholyblack/vigilant_eureka/network/PacketSendKey.java rename to src/main/java/me/itstheholyblack/vigilant_eureka/network/PacketSendWarp.java index e29ba1a..d09bbbf 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/network/PacketSendKey.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/network/PacketSendWarp.java @@ -13,7 +13,7 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -public class PacketSendKey implements IMessage { +public class PacketSendWarp implements IMessage { private BlockPos blockPos; @Override @@ -28,15 +28,15 @@ public void toBytes(ByteBuf buf) { buf.writeLong(blockPos.toLong()); } - public PacketSendKey() { + public PacketSendWarp() { // Calculate the position of the block we are looking at RayTraceResult result = Minecraft.getMinecraft().objectMouseOver; blockPos = result.getBlockPos(); } - public static class Handler implements IMessageHandler { + public static class Handler implements IMessageHandler { @Override - public IMessage onMessage(PacketSendKey message, MessageContext ctx) { + public IMessage onMessage(PacketSendWarp message, MessageContext ctx) { // Always use a construct like this to actually handle your message. This ensures that // your 'handle' code is run on the main Minecraft thread. 'onMessage' itself // is called on the networking thread so it is not safe to do a lot of things @@ -45,7 +45,7 @@ public IMessage onMessage(PacketSendKey message, MessageContext ctx) { return null; } - private void handle(PacketSendKey message, MessageContext ctx) { + private void handle(PacketSendWarp message, MessageContext ctx) { // This code is run on the server side. So you can do server-side calculations here EntityPlayerMP playerEntity = ctx.getServerHandler().player; World world = playerEntity.getEntityWorld(); @@ -56,9 +56,7 @@ private void handle(PacketSendKey message, MessageContext ctx) { } catch (NullPointerException e) { look = playerEntity.getPosition(); } - if (playerEntity.getCooldownTracker().hasCooldown(ModItems.warpBoots)) { - return; - } else { + if (!playerEntity.getCooldownTracker().hasCooldown(ModItems.warpBoots)) { playerEntity.getCooldownTracker().setCooldown(ModItems.warpBoots, 20); playerEntity.setPositionAndUpdate(look.getX(), look.getY() + 2, look.getZ()); PacketHandler.INSTANCE.sendToAll(new PacketEndericPoof(look.up(2))); diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/network/PacketSpawnBody.java b/src/main/java/me/itstheholyblack/vigilant_eureka/network/PacketSpawnBody.java new file mode 100644 index 0000000..d8c5cb9 --- /dev/null +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/network/PacketSpawnBody.java @@ -0,0 +1,62 @@ +package me.itstheholyblack.vigilant_eureka.network; + +import io.netty.buffer.ByteBuf; +import me.itstheholyblack.vigilant_eureka.entity.EntityPlayerBody; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.world.World; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.network.simpleimpl.IMessage; +import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; +import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public class PacketSpawnBody implements IMessage { + + boolean smallArms; + + @SideOnly(Side.CLIENT) + public PacketSpawnBody() { + smallArms = !(Minecraft.getMinecraft().player).getSkinType().equals("default"); + } + + @Override + public void fromBytes(ByteBuf buf) { + smallArms = buf.readBoolean(); + } + + @Override + public void toBytes(ByteBuf buf) { + buf.writeBoolean(smallArms); + } + + public static class Handler implements IMessageHandler { + @Override + public IMessage onMessage(PacketSpawnBody message, MessageContext ctx) { + // Always use a construct like this to actually handle your message. This ensures that + // your 'handle' code is run on the main Minecraft thread. 'onMessage' itself + // is called on the networking thread so it is not safe to do a lot of things + // here. + FMLCommonHandler.instance().getWorldThread(ctx.netHandler).addScheduledTask(() -> handle(message, ctx)); + return null; + } + + private void handle(PacketSpawnBody message, MessageContext ctx) { + EntityPlayerMP playerEntity = ctx.getServerHandler().player; + World world = playerEntity.getEntityWorld(); + + EntityPlayerBody e = new EntityPlayerBody(world); + e.setPosition(playerEntity.posX, playerEntity.posY + 1, playerEntity.posZ); + e.rotationYaw = (float) (180.0F * world.rand.nextDouble()); + e.renderYawOffset = e.rotationYaw; + + e.setSmallArms(message.smallArms); + e.setPlayerName(playerEntity.getName()); + e.setPlayerId(EntityPlayer.getUUID(playerEntity.getGameProfile())); + + world.spawnEntity(e); + } + } +} diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/proxy/ClientProxy.java b/src/main/java/me/itstheholyblack/vigilant_eureka/proxy/ClientProxy.java index 435bb82..03f05a7 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/proxy/ClientProxy.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/proxy/ClientProxy.java @@ -3,10 +3,12 @@ import me.itstheholyblack.vigilant_eureka.Reference; import me.itstheholyblack.vigilant_eureka.blocks.ModBlocks; import me.itstheholyblack.vigilant_eureka.blocks.tiles.LeyLineTile; +import me.itstheholyblack.vigilant_eureka.client.Icons; import me.itstheholyblack.vigilant_eureka.client.Keybinds; import me.itstheholyblack.vigilant_eureka.client.LeyLineTileRenderer; import me.itstheholyblack.vigilant_eureka.client.renderer.CustomBipedArmor; import me.itstheholyblack.vigilant_eureka.core.InputHandler; +import me.itstheholyblack.vigilant_eureka.entity.ModEntities; import me.itstheholyblack.vigilant_eureka.items.ModItems; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.RenderLivingBase; @@ -35,13 +37,14 @@ public class ClientProxy extends CommonProxy { public static void registerModels(ModelRegistryEvent event) { ModBlocks.initModels(); ModItems.initModels(); + ModEntities.initModels(); } @SideOnly(Side.CLIENT) - @SubscribeEvent @Override public void preInit(FMLPreInitializationEvent event) { super.preInit(event); + MinecraftForge.EVENT_BUS.register(Icons.INSTANCE); Keybinds.initWarpKey(); } @@ -52,7 +55,6 @@ public void preInit(FMLPreInitializationEvent event) { * @author Paul Fulham */ @SideOnly(Side.CLIENT) - @SubscribeEvent @Override public void init(FMLInitializationEvent event) { super.init(event); diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/proxy/CommonProxy.java b/src/main/java/me/itstheholyblack/vigilant_eureka/proxy/CommonProxy.java index 758a77b..cf37e9e 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/proxy/CommonProxy.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/proxy/CommonProxy.java @@ -1,13 +1,16 @@ package me.itstheholyblack.vigilant_eureka.proxy; +import com.google.common.collect.ImmutableMap; import me.itstheholyblack.vigilant_eureka.Reference; import me.itstheholyblack.vigilant_eureka.blocks.*; import me.itstheholyblack.vigilant_eureka.blocks.tiles.LeyLineTile; import me.itstheholyblack.vigilant_eureka.blocks.tiles.MovingCastleDoorTile; import me.itstheholyblack.vigilant_eureka.core.EventHandler; +import me.itstheholyblack.vigilant_eureka.entity.ModEntities; import me.itstheholyblack.vigilant_eureka.items.*; import me.itstheholyblack.vigilant_eureka.items.armor.InvisCap; import me.itstheholyblack.vigilant_eureka.items.armor.WarpBoots; +import me.itstheholyblack.vigilant_eureka.items.baubles.ItemTime; import me.itstheholyblack.vigilant_eureka.network.PacketHandler; import me.itstheholyblack.vigilant_eureka.world.WorldGenBismuth; import me.itstheholyblack.vigilant_eureka.world.WorldGenLey; @@ -17,8 +20,14 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.datafix.FixTypes; +import net.minecraft.util.datafix.IFixableData; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ModFixs; import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; @@ -28,14 +37,19 @@ import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.oredict.OreDictionary; +import javax.annotation.Nonnull; +import java.util.Map; + @Mod.EventBusSubscriber(modid = Reference.MOD_ID) public class CommonProxy { public void preInit(FMLPreInitializationEvent e) { - FMLLog.log.info("Registering Vigilant Eureka event handler."); + Reference.LOGGER.info("Registering Vigilant Eureka event handler."); MinecraftForge.EVENT_BUS.register(new EventHandler()); - FMLLog.log.info("Registering Vigilant Eureka networking."); + Reference.LOGGER.info("Registering Vigilant Eureka networking."); PacketHandler.registerMessages(Reference.MOD_ID); + ModEntities.init(); + registerTiles(); } public void init(FMLInitializationEvent e) { @@ -43,6 +57,9 @@ public void init(FMLInitializationEvent e) { GameRegistry.registerWorldGenerator(worldGenBismuth, 100); GameRegistry.registerWorldGenerator(new WorldGenLey(), 100); GameRegistry.addSmelting(ModItems.bismite, new ItemStack(ModItems.leyKey), 0.7F); + // fix the tiles + ModFixs fixes = FMLCommonHandler.instance().getDataFixer().init(Reference.MOD_ID, 1); + fixes.registerFix(FixTypes.BLOCK_ENTITY, new TileEntitySpaceFixer()); } public void postInit(FMLPostInitializationEvent e) { @@ -55,8 +72,11 @@ public static void registerBlocks(RegistryEvent.Register event) { event.getRegistry().register(new MovingCastleDoor()); event.getRegistry().register(new BlockBismuthOre()); event.getRegistry().register(new BlockLeyLine()); - GameRegistry.registerTileEntity(MovingCastleDoorTile.class, Reference.MOD_ID + ":castledoor"); - GameRegistry.registerTileEntity(LeyLineTile.class, Reference.MOD_KEY + "leytile"); + } + + private static void registerTiles() { + GameRegistry.registerTileEntity(MovingCastleDoorTile.class, new ResourceLocation(Reference.MOD_ID, "castledoor")); + GameRegistry.registerTileEntity(LeyLineTile.class, new ResourceLocation(Reference.MOD_ID, "leytile")); } @SubscribeEvent @@ -70,10 +90,40 @@ public static void registerItems(RegistryEvent.Register event) { event.getRegistry().register(new DimKey()); event.getRegistry().register(new WarpBoots()); event.getRegistry().register(new InvisCap()); + event.getRegistry().register(new ItemTime()); event.getRegistry().register(new ItemBismite()); event.getRegistry().register(new ItemLeyKey()); event.getRegistry().register(new ItemLeyRune()); event.getRegistry().register(new DebugStick()); + event.getRegistry().register(new ItemCard()); Items.FIREWORKS.setCreativeTab(CreativeTabs.MISC); // please and thank you } + + private static class TileEntitySpaceFixer implements IFixableData { + private final Map tileEntityNames; + + { + ImmutableMap.Builder nameMap = ImmutableMap.builder(); + nameMap.put("minecraft:19d2daed26722f2762d067603604a6d1f909f262leytile", "vigilant_eureka:leytile"); + nameMap.put("19d2daed26722f2762d067603604a6d1f909f262leytile", "vigilant_eureka:leytile"); + nameMap.put("minecraft:leytile", "vigilant_eureka:leytile"); + nameMap.put("leytile", "vigilant_eureka:leytile"); + tileEntityNames = nameMap.build(); + } + + @Override + public int getFixVersion() { + return 1; + } + + @Nonnull + @Override + public NBTTagCompound fixTagCompound(@Nonnull NBTTagCompound compound) { + String tileEntityLocation = compound.getString("id"); + + compound.setString("id", tileEntityNames.getOrDefault(tileEntityLocation, tileEntityLocation)); + + return compound; + } + } } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/util/ArrayUtil.java b/src/main/java/me/itstheholyblack/vigilant_eureka/util/ArrayUtil.java new file mode 100644 index 0000000..f9a7685 --- /dev/null +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/util/ArrayUtil.java @@ -0,0 +1,20 @@ +package me.itstheholyblack.vigilant_eureka.util; + +import java.util.Random; + +public class ArrayUtil { + private static Random r = new Random(); + + public static boolean contains(Object[] arr, Object item) { + for (Object n : arr) { + if (item.equals(n)) { + return true; + } + } + return false; + } + + public static T randomFromArr(T[] arr) { + return arr[r.nextInt(arr.length)]; + } +} diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/util/NBTUtil.java b/src/main/java/me/itstheholyblack/vigilant_eureka/util/NBTUtil.java new file mode 100644 index 0000000..3989c9b --- /dev/null +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/util/NBTUtil.java @@ -0,0 +1,24 @@ +package me.itstheholyblack.vigilant_eureka.util; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class NBTUtil { + public static NBTTagCompound getTagCompoundSafe(ItemStack stack) { + NBTTagCompound tagCompound = stack.getTagCompound(); + if (tagCompound == null) { + tagCompound = new NBTTagCompound(); + stack.setTagCompound(tagCompound); + } + return tagCompound; + } + + public static NBTTagCompound getPlayerPersist(EntityPlayer p) { + NBTTagCompound data = p.getEntityData(); + if (!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) { + data.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound()); + } + return data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); + } +} diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/util/RayTraceHelper.java b/src/main/java/me/itstheholyblack/vigilant_eureka/util/RayTraceHelper.java index 3a4bf7f..f40f744 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/util/RayTraceHelper.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/util/RayTraceHelper.java @@ -118,5 +118,4 @@ private static RayTraceResult tracePath(World world, float x, float y, float z, } return blockHit; } - } diff --git a/src/main/java/me/itstheholyblack/vigilant_eureka/world/WorldGenLey.java b/src/main/java/me/itstheholyblack/vigilant_eureka/world/WorldGenLey.java index b2f2789..ca4521a 100644 --- a/src/main/java/me/itstheholyblack/vigilant_eureka/world/WorldGenLey.java +++ b/src/main/java/me/itstheholyblack/vigilant_eureka/world/WorldGenLey.java @@ -48,12 +48,12 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkG // get template Template t = templateManager.get(world.getMinecraftServer(), r); // actual block level co-ords of chunk - int blockX = chunkX * 16; - int blockZ = chunkZ * 16; + int blockX = (chunkX * 16) + 8; + int blockZ = (chunkZ * 16) + 8; // get block level generation position int XModifier = random.nextInt(16); int ZModifier = random.nextInt(16); - // pick random values in ( + // pick random values in (0, 15) while (!(XModifier == 0 || XModifier == 15 || ZModifier == 0 || ZModifier == 15)) { XModifier = random.nextInt(16); ZModifier = random.nextInt(16); @@ -68,10 +68,8 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkG y = getGroundFromAbove(world, randX, randZ); } if (y < 0) { - System.out.println("Y < 0"); return; } - // System.out.format("Generating %s at (%d, %d, %d)\n", r.toString(), randX, y, randZ); PlacementSettings settings = new PlacementSettings(); BlockPos generationPos = new BlockPos(randX, y, randZ); settings.setRandom(world.rand); diff --git a/src/main/resources/assets/vigilant_eureka/lang/en_us.lang b/src/main/resources/assets/vigilant_eureka/lang/en_us.lang index 82527c0..91f9f06 100644 --- a/src/main/resources/assets/vigilant_eureka/lang/en_us.lang +++ b/src/main/resources/assets/vigilant_eureka/lang/en_us.lang @@ -7,18 +7,26 @@ item.vigilant_eureka.warp_boots.name=Warp Boots item.vigilant_eureka.invis_cap.name=Invisibility Cap item.vigilant_eureka.bismite.name=Bismite Deposit item.vigilant_eureka.ley_key.name=Crystalline Bismuth +item.vigilant_eureka.throwing_card.name=Throwing Card +item.vigilant_eureka.time.name=Time's Eye mouseovertext.dim_key=A key that opens many doors. That life has. Ed boy. mouseovertext.dim_door=A door. That moves you. To places. With motion. It's like magic, but better. mouseovertext.invis_cap=It's a cap that makes you invisible. Hey, that'd be cool as a cloak! mouseovertext.warp_boots=Boots that can outrun space and time, because that's definitely something your mortal feet can handle. mouseovertext.ley_key=Bismuth, melted into strange and alien shapes. Or just squares, one of the two. +mouseovertext.throwing_card=The card seems to hum with energy. Maybe you should throw it? +mouseovertext.time=A strange gilded eye-shaped amulet. What would happen if you opened it? itemGroup.vigilantEureka=Vigilant Eureka vigilant_eureka.keybind.warp_key=Warp with Warp Boots +vigilant_eureka.keybind.time_key=Open the Eye vigilant_eureka.gui.keybinds=Vigilant Eureka +message.door_set_success=Click +message.door_set_fail=It won't turn. + message.ley_link_good=It worked! message.ley_link_selflink=The feedback loop quickly decays to nothing... message.ley_link_doublelink=This link already exists! @@ -26,5 +34,10 @@ message.ley_link_twoway=Two way links aren't acceptable. message.ley_solve_good=The links pulse and strengthen. message.ley_solve_incomplete=The line isn't complete! +message.enter_ley=Something feels different. + +message.eye_already_open=The eye is stubbornly open - perhaps you must wait for it to close? + +message.body=Is that me? -message.enter_ley=Something feels different. \ No newline at end of file +entity.vigilant_eureka:player_body.name=Someone's body \ No newline at end of file diff --git a/src/main/resources/assets/vigilant_eureka/loot_tables/inject/simple_dungeon.json b/src/main/resources/assets/vigilant_eureka/loot_tables/inject/simple_dungeon.json new file mode 100644 index 0000000..e025865 --- /dev/null +++ b/src/main/resources/assets/vigilant_eureka/loot_tables/inject/simple_dungeon.json @@ -0,0 +1,40 @@ +{ + "__comment": "This table is injected as its own pool into minecraft:chests/simple_dungeon", + "pools": [ + { + "name": "main", + "rolls": 1, + "entries": [ + { + "type": "item", + "name": "vigilant_eureka:time", + "weight": 2, + "functions": [ + { + "function": "set_count", + "count": { + "min": 0, + "max": 1 + } + } + ] + }, + { + "type": "item", + "name": "vigilant_eureka:throwing_card", + "weight": 5, + "quality": 2, + "functions": [ + { + "function": "set_count", + "count": { + "min": 1, + "max": 10 + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/vigilant_eureka/models/item/throwing_card.json b/src/main/resources/assets/vigilant_eureka/models/item/throwing_card.json new file mode 100644 index 0000000..436976c --- /dev/null +++ b/src/main/resources/assets/vigilant_eureka/models/item/throwing_card.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "vigilant_eureka:items/card" + } +} diff --git a/src/main/resources/assets/vigilant_eureka/models/item/time.json b/src/main/resources/assets/vigilant_eureka/models/item/time.json new file mode 100644 index 0000000..8c995bb --- /dev/null +++ b/src/main/resources/assets/vigilant_eureka/models/item/time.json @@ -0,0 +1,14 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "vigilant_eureka:items/time" + }, + "overrides": [ + { + "predicate": { + "open_eye": 1 + }, + "model": "vigilant_eureka:item/time_open" + } + ] +} diff --git a/src/main/resources/assets/vigilant_eureka/models/item/time_open.json b/src/main/resources/assets/vigilant_eureka/models/item/time_open.json new file mode 100644 index 0000000..53d6425 --- /dev/null +++ b/src/main/resources/assets/vigilant_eureka/models/item/time_open.json @@ -0,0 +1,14 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "vigilant_eureka:items/time_open" + }, + "overrides": [ + { + "predicate": { + "open_eye": 0 + }, + "model": "vigilant_eureka:item/time" + } + ] +} diff --git a/src/main/resources/assets/vigilant_eureka/recipes/invis_cap.json b/src/main/resources/assets/vigilant_eureka/recipes/invis_cap.json index e983a6a..8fc0950 100644 --- a/src/main/resources/assets/vigilant_eureka/recipes/invis_cap.json +++ b/src/main/resources/assets/vigilant_eureka/recipes/invis_cap.json @@ -1,10 +1,10 @@ { - "type": "minecraft:crafting_shaped", - "pattern": [ - "LLL", - "LBL" - ], - "key": { + "type": "minecraft:crafting_shaped", + "pattern": [ + "LLL", + "LBL" + ], + "key": { "L": { "item": "minecraft:leather" }, diff --git a/src/main/resources/assets/vigilant_eureka/recipes/warp_boots.json b/src/main/resources/assets/vigilant_eureka/recipes/warp_boots.json index 17809cd..6c4eba6 100644 --- a/src/main/resources/assets/vigilant_eureka/recipes/warp_boots.json +++ b/src/main/resources/assets/vigilant_eureka/recipes/warp_boots.json @@ -1,10 +1,10 @@ { - "type": "minecraft:crafting_shaped", - "pattern": [ - "L L", - "LBL" - ], - "key": { + "type": "minecraft:crafting_shaped", + "pattern": [ + "L L", + "LBL" + ], + "key": { "L": { "item": "minecraft:leather" }, diff --git a/src/main/resources/assets/vigilant_eureka/textures/items/card.png b/src/main/resources/assets/vigilant_eureka/textures/items/card.png new file mode 100644 index 0000000..43972e2 Binary files /dev/null and b/src/main/resources/assets/vigilant_eureka/textures/items/card.png differ diff --git a/src/main/resources/assets/vigilant_eureka/textures/items/card.png.mcmeta b/src/main/resources/assets/vigilant_eureka/textures/items/card.png.mcmeta new file mode 100644 index 0000000..133c4a6 --- /dev/null +++ b/src/main/resources/assets/vigilant_eureka/textures/items/card.png.mcmeta @@ -0,0 +1,18 @@ +{ + "animation": { + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11 + ] + } +} \ No newline at end of file diff --git a/src/main/resources/assets/vigilant_eureka/textures/items/time.png b/src/main/resources/assets/vigilant_eureka/textures/items/time.png new file mode 100644 index 0000000..9728729 Binary files /dev/null and b/src/main/resources/assets/vigilant_eureka/textures/items/time.png differ diff --git a/src/main/resources/assets/vigilant_eureka/textures/items/time_open.png b/src/main/resources/assets/vigilant_eureka/textures/items/time_open.png new file mode 100644 index 0000000..d932778 Binary files /dev/null and b/src/main/resources/assets/vigilant_eureka/textures/items/time_open.png differ diff --git a/src/main/resources/assets/vigilant_eureka/textures/items/time_open_rend.png b/src/main/resources/assets/vigilant_eureka/textures/items/time_open_rend.png new file mode 100644 index 0000000..c853fc7 Binary files /dev/null and b/src/main/resources/assets/vigilant_eureka/textures/items/time_open_rend.png differ diff --git a/src/main/resources/assets/vigilant_eureka/textures/items/time_rend.png b/src/main/resources/assets/vigilant_eureka/textures/items/time_rend.png new file mode 100644 index 0000000..a2adecc Binary files /dev/null and b/src/main/resources/assets/vigilant_eureka/textures/items/time_rend.png differ diff --git a/src/main/resources/assets/vigilant_eureka/textures/models/armor/bugger_me_layer_1.png b/src/main/resources/assets/vigilant_eureka/textures/models/armor/bugger_me_layer_1.png index f5d8d63..35144e8 100644 Binary files a/src/main/resources/assets/vigilant_eureka/textures/models/armor/bugger_me_layer_1.png and b/src/main/resources/assets/vigilant_eureka/textures/models/armor/bugger_me_layer_1.png differ diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 15041e1..b2d502a 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,16 +1,18 @@ [ -{ - "modid": "vigilant_eureka", - "name": "Vigilant Eureka", - "description": "A mod that does things to the Minecraft.\nSource is available at https://github.com/tkdberger/vigilant-eureka", - "version": "0.0.2", - "mcversion": "1.12", - "url": "https://minecraft.curseforge.com/projects/vigilant-eureka", - "updateUrl": "", - "authorList": ["Edwan Vi"], - "credits": "Paul Fulham, for being the generous god they are.\nSamuel#2783 (sorry) for the basis of the key texture.\nBord Listian, for the Crystalline Bismuth texture.\nPeople smarter than me, for Forge.", - "logoFile": "", - "screenshots": [], - "dependencies": [] -} + { + "modid": "vigilant_eureka", + "name": "Vigilant Eureka", + "description": "A mod that does things to the Minecraft.\nSource is available at https://github.com/tkdberger/vigilant-eureka", + "version": "0.0.4", + "mcversion": "1.12", + "url": "https://minecraft.curseforge.com/projects/vigilant-eureka", + "updateUrl": "", + "authorList": [ + "Edwan Vi" + ], + "credits": "Paul Fulham, for being the generous god they are.\nSamuel#2783 (sorry) for the basis of the key texture.\nBord Listian, for the Crystalline Bismuth texture.\nPeople smarter than me, for Forge.", + "logoFile": "", + "screenshots": [], + "dependencies": ["Baubles (latest build best build)"] + } ]