From 705ac950caf4d8cfd6bca5b790fd1a6cac52ec41 Mon Sep 17 00:00:00 2001 From: cvrunmin Date: Sun, 12 Jun 2016 12:01:03 +0800 Subject: [PATCH] downgrade to 1.8.9 --- build.gradle | 6 +- .../github/cvronmin/railwayp/CommonProxy.java | 15 +- .../github/cvronmin/railwayp/Reference.java | 2 +- .../railwayp/block/BlockColorful.java | 25 +- .../railwayp/block/BlockNameBanner.java | 136 ++-- .../railwayp/block/BlockPlatformBanner.java | 223 +++---- .../railwayp/block/BlockPlatformDoor.java | 611 +++++++++++++----- .../railwayp/block/BlockPlatformGlass.java | 270 ++++---- .../railwayp/block/BlockRColorful.java | 21 +- .../railwayp/block/BlockRailNoticer.java | 177 +---- .../railwayp/block/BlockRouteSignage.java | 138 ++-- .../cvronmin/railwayp/block/BlockWHPF.java | 171 ++--- .../railwayp/block/DoorStructureHelper.java | 32 +- .../cvronmin/railwayp/client/ClientProxy.java | 18 +- .../client/gui/GuiNameBannerEditor.java | 19 +- .../cvronmin/railwayp/client/gui/GuiPen.java | 12 +- .../client/gui/GuiPlatformBannerEditor.java | 20 +- .../railwayp/client/gui/GuiWHPFEditor.java | 22 +- .../railwayp/client/model/ModelBlock.java | 36 +- .../renderer/TileEntityColorfulRenderer.java | 2 +- .../TileEntityNameBannerRenderer.java | 24 +- .../renderer/TileEntityPFDoorRenderer.java | 53 +- .../TileEntityPlatformBannerRenderer.java | 26 +- .../TileEntityRouteSignageRenderer.java | 35 +- .../renderer/TileEntityWHPFRenderer.java | 22 +- .../LayeredCustomColorMaskTexture.java | 113 ++-- .../texture/UnifedBannerTextures.java | 5 - .../cvronmin/railwayp/init/RPBlocks.java | 11 +- .../railwayp/init/RPCraftingManager.java | 342 +++++----- .../cvronmin/railwayp/init/RPItems.java | 2 +- .../cvronmin/railwayp/item/ItemEditor.java | 17 +- .../railwayp/item/ItemNameBanner.java | 28 +- .../railwayp/item/ItemPlatformBanner.java | 22 +- .../railwayp/item/ItemRouteSignage.java | 22 +- .../cvronmin/railwayp/item/ItemWHPF.java | 27 +- .../railwayp/network/CUpdateBannerByGui.java | 4 +- .../railwayp/network/MessagerFromClient.java | 4 +- .../railwayp/network/MessagerFromServer.java | 12 +- .../cvronmin/railwayp/network/RPPacket.java | 19 +- .../tileentity/TileEntityColorful.java | 5 +- .../tileentity/TileEntityNameBanner.java | 25 +- .../railwayp/tileentity/TileEntityPFDoor.java | 116 +--- .../tileentity/TileEntityPlatformBanner.java | 25 +- .../tileentity/TileEntityRailNoticer.java | 4 +- .../tileentity/TileEntityRouteSignage.java | 25 +- .../railwayp/tileentity/TileEntityWHPF.java | 23 +- .../github/cvronmin/railwayp/util/NTUtil.java | 2 +- .../railwayp/blockstates/platform_glass.json | 45 +- .../railwayp/blockstates/rail_noticer.json | 32 +- .../railwayp/blockstates/roof_whpf.json | 8 +- .../blockstates/wall_name_banner.json | 14 +- .../blockstates/wall_platform_banner.json | 14 +- .../railwayp/blockstates/wall_route_sign.json | 14 +- .../railwayp/blockstates/wall_whpf.json | 14 +- .../models/block/pfdoor_extension.json | 12 +- .../railwayp/models/block/pfglass_n.json | 22 + .../railwayp/models/block/pfglass_ne.json | 34 + .../railwayp/models/block/pfglass_ns.json | 22 + .../railwayp/models/block/pfglass_nse.json | 34 + .../railwayp/models/block/pfglass_nsew.json | 34 + .../railwayp/models/block/roof_whpf.json | 12 +- .../models/block/wall_platform_banner.json | 12 +- .../models/block/wall_route_sign.json | 12 +- .../railwayp/models/block/wall_whpf.json | 12 +- .../assets/railwayp/models/item/editor.json | 12 + .../railwayp/models/item/name_banner.json | 14 +- .../railwayp/models/item/platform_banner.json | 14 +- .../railwayp/models/item/platform_glass.json | 10 +- .../railwayp/models/item/rail_noticer.json | 24 +- .../railwayp/models/item/route_sign.json | 14 +- .../assets/railwayp/models/item/whpf.json | 14 +- 71 files changed, 1803 insertions(+), 1615 deletions(-) create mode 100644 src/main/resources/assets/railwayp/models/block/pfglass_n.json create mode 100644 src/main/resources/assets/railwayp/models/block/pfglass_ne.json create mode 100644 src/main/resources/assets/railwayp/models/block/pfglass_ns.json create mode 100644 src/main/resources/assets/railwayp/models/block/pfglass_nse.json create mode 100644 src/main/resources/assets/railwayp/models/block/pfglass_nsew.json diff --git a/build.gradle b/build.gradle index 1c05416..52eca0b 100644 --- a/build.gradle +++ b/build.gradle @@ -24,12 +24,12 @@ plugins { */ targetCompatibility = "1.7" sourceCompatibility = "1.7" -version = "1.1-mc1.9" +version = "1.1-mc1.8.9" group= "io.github.cvronmin.railwayp" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "railwayp" [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' minecraft { - version = "1.9-12.16.1.1887" + version = "1.8.9-11.15.1.1722" runDir = "run" // the mappings can be changed at any time, and must be in the following format. @@ -37,7 +37,7 @@ minecraft { // stable_# stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not allways work. // simply re-run your setup task after changing the mappings to update your workspace. - mappings = "stable_24" + mappings = "stable_20" // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. } diff --git a/src/main/java/io/github/cvronmin/railwayp/CommonProxy.java b/src/main/java/io/github/cvronmin/railwayp/CommonProxy.java index fbe0fe5..afbb67d 100644 --- a/src/main/java/io/github/cvronmin/railwayp/CommonProxy.java +++ b/src/main/java/io/github/cvronmin/railwayp/CommonProxy.java @@ -14,7 +14,7 @@ import io.github.cvronmin.railwayp.tileentity.TileEntityWHPF; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.network.INetHandler; @@ -56,18 +56,7 @@ private void registerEntity(){ GameRegistry.registerTileEntity(TileEntityColorful.class, "Colorful"); GameRegistry.registerTileEntity(TileEntityRailNoticer.class, "noticer"); } - protected void blockRend(Block block, String registerName){ - Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, - new ModelResourceLocation("railwayp:" + registerName, "inventory")); - } - protected void itemRend(Item item, String registerName){ - Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, - new ModelResourceLocation("railwayp:" + registerName, "inventory")); - } - protected void itemRend(Item item, int damage, String ideniter){ - Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, damage, - new ModelResourceLocation("railwayp:" + ideniter, "inventory")); - } + public EntityPlayer getPlayerFromNetHandler(INetHandler handler) { if (handler instanceof NetHandlerPlayServer) diff --git a/src/main/java/io/github/cvronmin/railwayp/Reference.java b/src/main/java/io/github/cvronmin/railwayp/Reference.java index 2dea368..064443d 100644 --- a/src/main/java/io/github/cvronmin/railwayp/Reference.java +++ b/src/main/java/io/github/cvronmin/railwayp/Reference.java @@ -3,7 +3,7 @@ public class Reference { public static final String MODID = "railwayp"; public static final String NAME = "StatCraft"; - public static final String VERSION = "1.1-mc1.9"; + public static final String VERSION = "1.1-mc1.8.9"; public static final String CPROXY = "io.github.cvronmin.railwayp.client" + ".ClientProxy"; public static final String SPROXY = "io.github.cvronmin.railwayp" + ".CommonProxy"; } diff --git a/src/main/java/io/github/cvronmin/railwayp/block/BlockColorful.java b/src/main/java/io/github/cvronmin/railwayp/block/BlockColorful.java index 451a5ff..4c52db2 100644 --- a/src/main/java/io/github/cvronmin/railwayp/block/BlockColorful.java +++ b/src/main/java/io/github/cvronmin/railwayp/block/BlockColorful.java @@ -1,8 +1,6 @@ package io.github.cvronmin.railwayp.block; -import io.github.cvronmin.railwayp.init.RPItems; import io.github.cvronmin.railwayp.tileentity.TileEntityColorful; -import io.github.cvronmin.railwayp.tileentity.TileEntityPlatformBanner; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -11,9 +9,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockRenderLayer; -import net.minecraft.util.EnumBlockRenderType; -import net.minecraft.util.math.BlockPos; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -22,28 +19,28 @@ public class BlockColorful extends BlockContainer{ public BlockColorful(){ - this(Material.CLAY); + this(Material.clay); } public BlockColorful(Material material) { super(material); - setCreativeTab(CreativeTabs.BUILDING_BLOCKS); + setCreativeTab(CreativeTabs.tabBlock); } @SideOnly(Side.CLIENT) - public BlockRenderLayer getBlockLayer() + public EnumWorldBlockLayer getBlockLayer() { - return BlockRenderLayer.CUTOUT_MIPPED; + return EnumWorldBlockLayer.CUTOUT_MIPPED; } /** * The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render */ - public EnumBlockRenderType getRenderType(IBlockState state) + public int getRenderType() { - return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; + return 2; } /** * Used to determine ambient occlusion and culling when rebuilding chunks for render */ - public boolean isOpaqueCube(IBlockState state) + public boolean isOpaqueCube() { return false; } @@ -78,7 +75,7 @@ public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) ItemStack itemstack = this.getTileDataItemStack(worldIn, pos, state); return itemstack != null ? itemstack : new ItemStack(this); } - public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te, ItemStack stack) + public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te) { if (te instanceof TileEntityColorful) { @@ -94,7 +91,7 @@ public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBloc } else { - super.harvestBlock(worldIn, player, pos, state, (TileEntity)null, stack); + super.harvestBlock(worldIn, player, pos, state, (TileEntity)null); } } @Override diff --git a/src/main/java/io/github/cvronmin/railwayp/block/BlockNameBanner.java b/src/main/java/io/github/cvronmin/railwayp/block/BlockNameBanner.java index fea9fde..c2fd096 100644 --- a/src/main/java/io/github/cvronmin/railwayp/block/BlockNameBanner.java +++ b/src/main/java/io/github/cvronmin/railwayp/block/BlockNameBanner.java @@ -9,17 +9,16 @@ import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyInteger; -import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumBlockRenderType; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -28,18 +27,26 @@ public class BlockNameBanner extends BlockContainer{ public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public static final PropertyInteger ROTATION = PropertyInteger.create("rotation", 0, 15); - //protected static final AxisAlignedBB AABB = new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D); - public BlockNameBanner() { - super(Material.WOOD); + super(Material.wood); this.disableStats(); + float f = 0.25F; + float f1 = 1.0F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); } - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) + public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) { - return NULL_AABB; + return null; } - public boolean isFullCube(IBlockState state) + + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos) + { + this.setBlockBoundsBasedOnState(worldIn, pos); + return super.getSelectedBoundingBox(worldIn, pos); + } + public boolean isFullCube() { return false; } @@ -48,27 +55,11 @@ public boolean isPassable(IBlockAccess worldIn, BlockPos pos) { return true; } - /** - * The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render - */ - public EnumBlockRenderType getRenderType(IBlockState state) - { - return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; - } - /** - * Used to determine ambient occlusion and culling when rebuilding chunks for render - */ - public boolean isOpaqueCube(IBlockState state) + + public boolean isOpaqueCube() { return false; } - /** - * Return true if an entity can be spawned inside the block (used to get the player's bed spawn location) - */ - public boolean canSpawnInBlock() - { - return true; - } public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityNameBanner(); @@ -111,7 +102,7 @@ public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState s } } - public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te, ItemStack stack) + public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te) { if (te instanceof TileEntityNameBanner) { @@ -127,7 +118,7 @@ public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBloc } else { - super.harvestBlock(worldIn, player, pos, state, (TileEntity)null, stack); + super.harvestBlock(worldIn, player, pos, state, (TileEntity)null); } } @SideOnly(Side.CLIENT) @@ -135,24 +126,32 @@ public Item getItem(World worldIn, BlockPos pos) { return RPItems.name_banner; } - - protected static final AxisAlignedBB NORTH_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.875D, 1D, 0.78125, 1.0D); - protected static final AxisAlignedBB SOUTH_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1D, 0.78125D, 0.125); - protected static final AxisAlignedBB WEST_AABB = new AxisAlignedBB(0.875D, 0.0D, 0.0D, 1.0D, 0.78125D, 1.0D); - protected static final AxisAlignedBB EAST_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.125D, 0.78125D, 1.0D); - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) + public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) { - switch ((EnumFacing)state.getValue(FACING)) + EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING); + float f = 0.0F; + f=0.109375f; + float f1 = 0.78125F; + f1=0.890625f; + float f2 = 0.0F; + float f3 = 1.0F; + float f4 = 0.125F; + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + + switch (BlockNameBanner.SwitchEnumFacing.FACING_LOOKUP[enumfacing.ordinal()]) { - case NORTH: + case 1: default: - return NORTH_AABB; - case SOUTH: - return SOUTH_AABB; - case WEST: - return WEST_AABB; - case EAST: - return EAST_AABB; + this.setBlockBounds(f2, f, 1.0F - f4, f3, f1, 1.0F); + break; + case 2: + this.setBlockBounds(f2, f, 0.0F, f3, f1, f4); + break; + case 3: + this.setBlockBounds(1.0F - f4, f, f2, 1.0F, f1, f3); + break; + case 4: + this.setBlockBounds(0.0F, f, f2, f4, f1, f3); } } /** @@ -178,9 +177,52 @@ public int getMetaFromState(IBlockState state) return ((EnumFacing)state.getValue(FACING)).getIndex(); } - protected BlockStateContainer createBlockState() + protected BlockState createBlockState() + { + return new BlockState(this, new IProperty[] {FACING}); + } + static final class SwitchEnumFacing { - return new BlockStateContainer(this, new IProperty[] {FACING}); + static final int[] FACING_LOOKUP = new int[EnumFacing.values().length]; + + static + { + try + { + FACING_LOOKUP[EnumFacing.NORTH.ordinal()] = 1; + } + catch (NoSuchFieldError var4) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.SOUTH.ordinal()] = 2; + } + catch (NoSuchFieldError var3) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.WEST.ordinal()] = 3; + } + catch (NoSuchFieldError var2) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.EAST.ordinal()] = 4; + } + catch (NoSuchFieldError var1) + { + ; + } + } } } diff --git a/src/main/java/io/github/cvronmin/railwayp/block/BlockPlatformBanner.java b/src/main/java/io/github/cvronmin/railwayp/block/BlockPlatformBanner.java index aefc3d4..3db5d53 100644 --- a/src/main/java/io/github/cvronmin/railwayp/block/BlockPlatformBanner.java +++ b/src/main/java/io/github/cvronmin/railwayp/block/BlockPlatformBanner.java @@ -6,25 +6,20 @@ import io.github.cvronmin.railwayp.tileentity.TileEntityPlatformBanner; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; -import net.minecraft.block.BlockHorizontal; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyInteger; -import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockRenderLayer; -import net.minecraft.util.EnumBlockRenderType; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -32,18 +27,30 @@ public class BlockPlatformBanner extends BlockContainer { - public static final PropertyDirection FACING = BlockHorizontal.FACING; - //protected static final AxisAlignedBB AABB = new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D); + public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); + public static final PropertyInteger ROTATION = PropertyInteger.create("rotation", 0, 15); + protected BlockPlatformBanner() { - super(Material.WOOD); + super(Material.wood); + float f = 0.25F; + float f1 = 1.0F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); + } + + public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) + { + return null; } - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos) { - return NULL_AABB; + this.setBlockBoundsBasedOnState(worldIn, pos); + return super.getSelectedBoundingBox(worldIn, pos); } - public boolean isFullCube(IBlockState state) + + public boolean isFullCube() { return false; } @@ -52,27 +59,12 @@ public boolean isPassable(IBlockAccess worldIn, BlockPos pos) { return true; } - /** - * The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render - */ - public EnumBlockRenderType getRenderType(IBlockState state) - { - return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; - } - /** - * Used to determine ambient occlusion and culling when rebuilding chunks for render - */ - public boolean isOpaqueCube(IBlockState state) + + public boolean isOpaqueCube() { return false; } - /** - * Return true if an entity can be spawned inside the block (used to get the player's bed spawn location) - */ - public boolean canSpawnInBlock() - { - return true; - } + /** * Returns a new instance of a block's tile entity class. Called on placing the block. */ @@ -90,7 +82,14 @@ public Item getItemDropped(IBlockState state, Random rand, int fortune) { return RPItems.platform_banner; } - private ItemStack getTileDataItemStack(World worldIn, BlockPos pos, IBlockState state) + + /** + * Spawns this Block's drops into the World as EntityItems. + * + * @param chance The chance that each Item is actually spawned (1.0 = always, 0.0 = never) + * @param fortune The player's fortune level + */ + public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune) { TileEntity tileentity = worldIn.getTileEntity(pos); @@ -104,36 +103,15 @@ private ItemStack getTileDataItemStack(World worldIn, BlockPos pos, IBlockState nbttagcompound.removeTag("z"); nbttagcompound.removeTag("id"); itemstack.setTagInfo("BlockEntityTag", nbttagcompound); - return itemstack; + spawnAsEntity(worldIn, pos, itemstack); } else - { - return null; - } - - } - - public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) - { - ItemStack itemstack = this.getTileDataItemStack(worldIn, pos, state); - return itemstack != null ? itemstack : new ItemStack(RPItems.platform_banner); - } - /** - * Spawns this Block's drops into the World as EntityItems. - */ - public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune) - { { super.dropBlockAsItemWithChance(worldIn, pos, state, chance, fortune); } } - public boolean canPlaceBlockAt(World worldIn, BlockPos pos) - { - return !this.hasInvalidNeighbor(worldIn, pos) && super.canPlaceBlockAt(worldIn, pos); - } - - public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te, ItemStack stack) + public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te) { if (te instanceof TileEntityPlatformBanner) { @@ -149,34 +127,10 @@ public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBloc } else { - super.harvestBlock(worldIn, player, pos, state, (TileEntity)null, stack); + super.harvestBlock(worldIn, player, pos, state, (TileEntity)null); } } - @Override - public java.util.List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) - { - TileEntity te = world.getTileEntity(pos); - java.util.List ret = new java.util.ArrayList(); - if (te instanceof TileEntityPlatformBanner) - { - TileEntityPlatformBanner banner = (TileEntityPlatformBanner)te; - ItemStack item = new ItemStack(RPItems.platform_banner, 1); - NBTTagCompound nbttagcompound = new NBTTagCompound(); - te.writeToNBT(nbttagcompound); - nbttagcompound.removeTag("x"); - nbttagcompound.removeTag("y"); - nbttagcompound.removeTag("z"); - nbttagcompound.removeTag("id"); - item.setTagInfo("BlockEntityTag", nbttagcompound); - ret.add(item); - } - else - { - ret.add(new ItemStack(RPItems.platform_banner, 1)); - } - return ret; - } @SideOnly(Side.CLIENT) public Item getItem(World worldIn, BlockPos pos) { @@ -185,32 +139,42 @@ public Item getItem(World worldIn, BlockPos pos) public static class BlockBannerHanging extends BlockPlatformBanner { - protected static final AxisAlignedBB NORTH_AABB = new AxisAlignedBB(0.0D, 0.109375, 0.875D, 1.0D, 0.890625, 1.0D); - protected static final AxisAlignedBB SOUTH_AABB = new AxisAlignedBB(0.0D, 0.109375f, 0.0D, 1.0D, 0.890625f, 0.125D); - protected static final AxisAlignedBB WEST_AABB = new AxisAlignedBB(0.875, 0.109375f, 0.0D, 1.0D, 0.890625f, 1.0D); - protected static final AxisAlignedBB EAST_AABB = new AxisAlignedBB(0.0D, 0.109375f, 0.0D, 0.125D, 0.890625f, 1.0D); + public BlockBannerHanging() { this.disableStats(); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); } - - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) + public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) { - switch ((EnumFacing)state.getValue(FACING)) + EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING); + float f = 0.0F; + f=0.109375f; + float f1 = 0.78125F; + f1=0.890625f; + float f2 = 0.0F; + float f3 = 1.0F; + float f4 = 0.125F; + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + + switch (BlockPlatformBanner.SwitchEnumFacing.FACING_LOOKUP[enumfacing.ordinal()]) { - case NORTH: + case 1: default: - return NORTH_AABB; - case SOUTH: - return SOUTH_AABB; - case WEST: - return WEST_AABB; - case EAST: - return EAST_AABB; + this.setBlockBounds(f2, f, 1.0F - f4, f3, f1, 1.0F); + break; + case 2: + this.setBlockBounds(f2, f, 0.0F, f3, f1, f4); + break; + case 3: + this.setBlockBounds(1.0F - f4, f, f2, 1.0F, f1, f3); + break; + case 4: + this.setBlockBounds(0.0F, f, f2, f4, f1, f3); } } + /** * Called when a neighboring block changes. */ @@ -218,31 +182,15 @@ public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state { EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); - if (!worldIn.getBlockState(pos.offset(enumfacing.getOpposite())).getMaterial().isSolid()) +/* if (!worldIn.getBlockState(pos.offset(enumfacing.getOpposite())).getBlock().getMaterial().isSolid()) { this.dropBlockAsItem(worldIn, pos, state, 0); worldIn.setBlockToAir(pos); - } + }*/ super.onNeighborBlockChange(worldIn, pos, state, neighborBlock); } - /** - * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the - * passed blockstate. - */ - public IBlockState withRotation(IBlockState state, Rotation rot) - { - return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); - } - /** - * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the - * passed blockstate. - */ - public IBlockState withMirror(IBlockState state, Mirror mirrorIn) - { - return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); - } /** * Convert the given metadata into a BlockState for this Block */ @@ -266,10 +214,53 @@ public int getMetaFromState(IBlockState state) return ((EnumFacing)state.getValue(FACING)).getIndex(); } - protected BlockStateContainer createBlockState() + protected BlockState createBlockState() { - return new BlockStateContainer(this, new IProperty[] {FACING}); + return new BlockState(this, new IProperty[] {FACING}); } } + static final class SwitchEnumFacing + { + static final int[] FACING_LOOKUP = new int[EnumFacing.values().length]; + + static + { + try + { + FACING_LOOKUP[EnumFacing.NORTH.ordinal()] = 1; + } + catch (NoSuchFieldError var4) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.SOUTH.ordinal()] = 2; + } + catch (NoSuchFieldError var3) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.WEST.ordinal()] = 3; + } + catch (NoSuchFieldError var2) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.EAST.ordinal()] = 4; + } + catch (NoSuchFieldError var1) + { + ; + } + } + } } \ No newline at end of file diff --git a/src/main/java/io/github/cvronmin/railwayp/block/BlockPlatformDoor.java b/src/main/java/io/github/cvronmin/railwayp/block/BlockPlatformDoor.java index bbf4ffb..2efcb34 100644 --- a/src/main/java/io/github/cvronmin/railwayp/block/BlockPlatformDoor.java +++ b/src/main/java/io/github/cvronmin/railwayp/block/BlockPlatformDoor.java @@ -7,36 +7,29 @@ import io.github.cvronmin.railwayp.tileentity.TileEntityPFDoor; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; -import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.BlockPistonExtension; import net.minecraft.block.BlockSnow; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.EnumPushReaction; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyDirection; -import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityPiston; -import net.minecraft.util.BlockRenderLayer; +//import net.minecraft.tileentity.TileEntityPiston; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.math.AxisAlignedBB; -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.util.EnumWorldBlockLayer; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -45,24 +38,28 @@ public class BlockPlatformDoor { public static class Base extends Block { - public static final PropertyDirection FACING = BlockHorizontal.FACING; + public static final PropertyDirection FACING = PropertyDirection.create("facing"); public static final PropertyBool EXTENDED = PropertyBool.create("extended"); public static final PropertyBool POWERED = PropertyBool.create("powered"); public Base() { - super(Material.GLASS); + super(Material.glass); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(EXTENDED, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false))); - this.setSoundType(SoundType.STONE); + this.setStepSound(soundTypePiston); this.setHardness(0.5F); - this.setCreativeTab(CreativeTabs.REDSTONE); + this.setCreativeTab(CreativeTabs.tabRedstone); } @SideOnly(Side.CLIENT) - public BlockRenderLayer getBlockLayer() + public EnumWorldBlockLayer getBlockLayer() { - return BlockRenderLayer.CUTOUT_MIPPED; + return EnumWorldBlockLayer.CUTOUT_MIPPED; + } + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side) + { + return worldIn.getBlockState(pos).getBlock() == this ? false : super.shouldSideBeRendered(worldIn, pos, side); } - public boolean canProvidePower() { return true; @@ -216,7 +213,7 @@ public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState sta } worldIn.setBlockState(pos, state.withProperty(EXTENDED, Boolean.valueOf(true)).withProperty(POWERED, Boolean.valueOf(true)), 2); - worldIn.playSound(null, pos,SoundEvents.BLOCK_PISTON_EXTEND, SoundCategory.BLOCKS, 0.5F, worldIn.rand.nextFloat() * 0.25F + 0.6F); + worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "tile.piston.out", 0.5F, worldIn.rand.nextFloat() * 0.25F + 0.6F); } else if (eventID == 1) { @@ -230,37 +227,51 @@ else if (eventID == 1) worldIn.setBlockState(pos, RPBlocks.platform_door_extension.getDefaultState().withProperty(Moving.FACING, enumfacing), 3); worldIn.setTileEntity(pos, Moving.newTileEntity(this.getStateFromMeta(eventParam), enumfacing, false, true)); worldIn.setBlockToAir(pos.offset(enumfacing)); - worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_PISTON_CONTRACT, SoundCategory.BLOCKS, 0.5F, worldIn.rand.nextFloat() * 0.15F + 0.6F); + worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "tile.piston.in", 0.5F, worldIn.rand.nextFloat() * 0.15F + 0.6F); } return true; } - protected static final AxisAlignedBB PISTON_BASE_EAST_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.4D, 1.0D, 1.0D, 0.6D); - protected static final AxisAlignedBB PISTON_BASE_WEST_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.4D, 1.0D, 1.0D, 1.0D); - protected static final AxisAlignedBB PISTON_BASE_SOUTH_AABB = new AxisAlignedBB(0.4D, 0.0D, 0.0D, .6D, 1.0D, 1.0D); - protected static final AxisAlignedBB PISTON_BASE_NORTH_AABB = new AxisAlignedBB(0.4D, 0.0D, 0.0D, .6D, 1.0D, 1.0D); - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) + public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) { - /*if (((Boolean)state.getValue(EXTENDED)).booleanValue()) - {*/ - switch ((EnumFacing)state.getValue(FACING)) + IBlockState iblockstate = worldIn.getBlockState(pos); + + if (iblockstate.getBlock() == this) + { + float f = 0.25F; + EnumFacing enumfacing = (EnumFacing)iblockstate.getValue(FACING); + + if (enumfacing != null) { - default: - case NORTH: - return PISTON_BASE_NORTH_AABB; - case SOUTH: - return PISTON_BASE_SOUTH_AABB; - case WEST: - return PISTON_BASE_WEST_AABB; - case EAST: - return PISTON_BASE_EAST_AABB; + switch (Base.SwitchEnumFacing.FACING_LOOKUP[enumfacing.ordinal()]) + { + case 1: + this.setBlockBounds(0.4F, 0.0F, 0.0F, 0.6F, 1.0F, 1.0F); + break; + case 2: + this.setBlockBounds(0.4F, 0.0F, 0.0F, 0.6F, 1.0F, 1.0F); + break; + case 3: + this.setBlockBounds(0.0F, 0.0F, 0.4F, 1.0F, 1.0F, 0.6F); + break; + case 4: + this.setBlockBounds(0.0F, 0.0F, 0.4F, 1.0F, 1.0F, 0.6F); + } } - /*} + } else { - return FULL_BLOCK_AABB; - }*/ + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } + + /** + * Sets the block's bounds for rendering it as an item + */ + public void setBlockBoundsForItemRender() + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } /** @@ -268,9 +279,17 @@ public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, Bloc * * @param collidingEntity the Entity colliding with this Block */ - public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB p_185477_4_, List p_185477_5_, Entity p_185477_6_) + public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) { - addCollisionBoxToList(pos, p_185477_4_, p_185477_5_, state.getBoundingBox(worldIn, pos)); +// this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + this.setBlockBoundsBasedOnState(worldIn, pos); + super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity); + } + + public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) + { + this.setBlockBoundsBasedOnState(worldIn, pos); + return super.getCollisionBoundingBox(worldIn, pos, state); } public boolean isFullCube() @@ -304,56 +323,59 @@ public static EnumFacing getFacingFromEntity(World worldIn, BlockPos clickedBloc return entityIn.getHorizontalFacing().getOpposite(); } - public static boolean func_185646_a(IBlockState p_185646_0_, World worldIn, BlockPos pos, EnumFacing facing, boolean p_185646_4_) - { - Block block = p_185646_0_.getBlock(); - - if (block == Blocks.OBSIDIAN) - { - return false; - } - else if (!worldIn.getWorldBorder().contains(pos)) - { - return false; - } - else if (pos.getY() >= 0 && (facing != EnumFacing.DOWN || pos.getY() != 0)) - { - if (pos.getY() <= worldIn.getHeight() - 1 && (facing != EnumFacing.UP || pos.getY() != worldIn.getHeight() - 1)) - { - if (block != RPBlocks.platform_door_base) - { - if (p_185646_0_.getBlockHardness(worldIn, pos) == -1.0F) - { - return false; - } - - if (p_185646_0_.getMobilityFlag() == EnumPushReaction.BLOCK) - { - return false; - } - - if (p_185646_0_.getMobilityFlag() == EnumPushReaction.DESTROY) - { - return p_185646_4_; - } - } - else if (((Boolean)p_185646_0_.getValue(EXTENDED)).booleanValue()) - { - return false; - } + public static boolean canPush(Block blockIn, World worldIn, BlockPos pos, EnumFacing direction, boolean allowDestroy) + { + if (blockIn == Blocks.obsidian) + { + return false; + } + else if (!worldIn.getWorldBorder().contains(pos)) + { + return false; + } + else if (pos.getY() >= 0 && (direction != EnumFacing.DOWN || pos.getY() != 0)) + { + if (pos.getY() <= worldIn.getHeight() - 1 && (direction != EnumFacing.UP || pos.getY() != worldIn.getHeight() - 1)) + { + if (blockIn != RPBlocks.platform_door_base) + { + if (blockIn.getBlockHardness(worldIn, pos) == -1.0F) + { + return false; + } + + if (blockIn.getMobilityFlag() == 2) + { + return false; + } + + if (blockIn.getMobilityFlag() == 1) + { + if (!allowDestroy) + { + return false; + } + + return true; + } + } + else if (((Boolean)worldIn.getBlockState(pos).getValue(EXTENDED)).booleanValue()) + { + return false; + } - return !block.hasTileEntity(p_185646_0_); - } - else - { - return false; - } - } - else - { - return false; - } - } + return !(blockIn.hasTileEntity(worldIn.getBlockState(pos))); + } + else + { + return false; + } + } + else + { + return false; + } + } private boolean doMove(World worldIn, BlockPos pos, EnumFacing direction, boolean extending) { @@ -474,57 +496,77 @@ public int getMetaFromState(IBlockState state) return i; } - protected BlockStateContainer createBlockState() - { - return new BlockStateContainer(this, new IProperty[] {FACING, EXTENDED, POWERED}); - } - public boolean isFullCube(IBlockState state) + protected BlockState createBlockState() { - return false; + return new BlockState(this, new IProperty[] {FACING, EXTENDED, POWERED}); } - /** - * Used to determine ambient occlusion and culling when rebuilding chunks for render - */ - public boolean isOpaqueCube(IBlockState state) - { - return false; - } + static final class SwitchEnumFacing + { + static final int[] FACING_LOOKUP = new int[EnumFacing.values().length]; + + static + { + try + { + FACING_LOOKUP[EnumFacing.NORTH.ordinal()] = 1; + } + catch (NoSuchFieldError var4) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.SOUTH.ordinal()] = 2; + } + catch (NoSuchFieldError var3) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.WEST.ordinal()] = 3; + } + catch (NoSuchFieldError var2) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.EAST.ordinal()] = 4; + } + catch (NoSuchFieldError var1) + { + ; + } + } + } } public static class Extension extends Block { - public static final PropertyDirection FACING = BlockHorizontal.FACING; + public static final PropertyDirection FACING = PropertyDirection.create("facing"); public static final PropertyBool SHORT = PropertyBool.create("short"); public Extension() { - super(Material.GLASS); + super(Material.glass); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(SHORT, Boolean.valueOf(false))); - this.setSoundType(SoundType.STONE); + this.setStepSound(soundTypePiston); this.setHardness(0.5F); } - public boolean isFullCube(IBlockState state) - { - return false; - } - - /** - * Used to determine ambient occlusion and culling when rebuilding chunks for render - */ - public boolean isOpaqueCube(IBlockState state) - { - return false; - } @SideOnly(Side.CLIENT) - public BlockRenderLayer getBlockLayer() + public EnumWorldBlockLayer getBlockLayer() { - return BlockRenderLayer.CUTOUT_MIPPED; + return EnumWorldBlockLayer.CUTOUT_MIPPED; } @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) + public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side) { - return blockState.getBlock() == this ? false : super.shouldSideBeRendered(blockState, blockAccess, pos, side); + return worldIn.getBlockState(pos).getBlock() == this ? false : super.shouldSideBeRendered(worldIn, pos, side); } public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) { @@ -561,6 +603,16 @@ public void breakBlock(World worldIn, BlockPos pos, IBlockState state) } } + public boolean isOpaqueCube() + { + return false; + } + + public boolean isFullCube() + { + return false; + } + public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { return false; @@ -582,26 +634,103 @@ public int quantityDropped(Random random) return 0; } - protected static final AxisAlignedBB PISTON_EXTENSION_EAST_WEST_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.45D, 1.0D, 1.0D, 0.55D); - protected static final AxisAlignedBB PISTON_EXTENSION_NORTH_SOUTH_AABB = new AxisAlignedBB(0.45D, 0.0D, 0.0D, 0.55D, 1.0D, 1.0D); - - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) + /** + * Add all collision boxes of this Block to the list that intersect with the given mask. + * + * @param collidingEntity the Entity colliding with this Block + */ + public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) { - switch ((EnumFacing)state.getValue(FACING)) +/* this.applyHeadBounds(state); + super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity); + this.applyCoreBounds(state);*/ + switch (Extension.SwitchEnumFacing.FACING_LOOKUP[((EnumFacing)state.getValue(FACING)).ordinal()]) { - default: - case NORTH: - case SOUTH: - return PISTON_EXTENSION_NORTH_SOUTH_AABB; - case WEST: - case EAST: - return PISTON_EXTENSION_EAST_WEST_AABB; + case 1: + this.setBlockBounds(0.45F, 0.0F, 0.0F, 0.55F, 1.0F, 1.0F); + break; + case 2: + this.setBlockBounds(0.45F, 0.0F, 0.0F, 0.55F, 1.0F, 1.0F); + break; + case 3: + this.setBlockBounds(0.0F, 0.0F, 0.45F, 1.0F, 1.0F, 0.55F); + break; + case 4: + this.setBlockBounds(0.0F, 0.0F, 0.45F, 1.0F, 1.0F, 0.55F); } + super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity); +// this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } + private void applyCoreBounds(IBlockState state) + { + float f = 0.25F; + float f1 = 0.375F; + float f2 = 0.625F; + float f3 = 0.25F; + float f4 = 0.75F; - public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB p_185477_4_, List p_185477_5_, Entity p_185477_6_) + switch (Extension.SwitchEnumFacing.FACING_LOOKUP[((EnumFacing)state.getValue(FACING)).ordinal()]) + { + case 1: + this.setBlockBounds(0.25F, 0.375F, 0.25F, 0.75F, 0.625F, 1.0F); + break; + case 2: + this.setBlockBounds(0.25F, 0.375F, 0.0F, 0.75F, 0.625F, 0.75F); + break; + case 3: + this.setBlockBounds(0.375F, 0.25F, 0.25F, 0.625F, 0.75F, 1.0F); + break; + case 4: + this.setBlockBounds(0.0F, 0.375F, 0.25F, 0.75F, 0.625F, 0.75F); + } + } + + public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) + { +// this.applyHeadBounds(worldIn.getBlockState(pos)); + IBlockState iblockstate = worldIn.getBlockState(pos); + EnumFacing enumfacing = (EnumFacing)iblockstate.getValue(FACING); + if (enumfacing != null) + { + switch (Extension.SwitchEnumFacing.FACING_LOOKUP[enumfacing.ordinal()]) + { + case 1: + this.setBlockBounds(0.45F, 0.0F, 0.0F, 0.55F, 1.0F, 1.0F); + break; + case 2: + this.setBlockBounds(0.45F, 0.0F, 0.0F, 0.55F, 1.0F, 1.0F); + break; + case 3: + this.setBlockBounds(0.0F, 0.0F, 0.45F, 1.0F, 1.0F, 0.55F); + break; + case 4: + this.setBlockBounds(0.0F, 0.0F, 0.45F, 1.0F, 1.0F, 0.55F); + } + } + } + + public void applyHeadBounds(IBlockState state) { - addCollisionBoxToList(pos, p_185477_4_, p_185477_5_, state.getBoundingBox(worldIn, pos)); + float f = 0.25F; + EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); + + if (enumfacing != null) + { + switch (Extension.SwitchEnumFacing.FACING_LOOKUP[enumfacing.ordinal()]) + { + case 1: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.25F); + break; + case 2: + this.setBlockBounds(0.0F, 0.0F, 0.75F, 1.0F, 1.0F, 1.0F); + break; + case 3: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.25F, 1.0F, 1.0F); + break; + case 4: + this.setBlockBounds(0.75F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } } /** @@ -653,10 +782,54 @@ public int getMetaFromState(IBlockState state) return i; } - protected BlockStateContainer createBlockState() + protected BlockState createBlockState() { - return new BlockStateContainer(this, new IProperty[] {FACING, SHORT}); + return new BlockState(this, new IProperty[] {FACING, SHORT}); } + + static final class SwitchEnumFacing + { + static final int[] FACING_LOOKUP = new int[EnumFacing.values().length]; + + static + { + try + { + FACING_LOOKUP[EnumFacing.NORTH.ordinal()] = 1; + } + catch (NoSuchFieldError var4) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.SOUTH.ordinal()] = 2; + } + catch (NoSuchFieldError var3) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.WEST.ordinal()] = 3; + } + catch (NoSuchFieldError var2) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.EAST.ordinal()] = 4; + } + catch (NoSuchFieldError var1) + { + ; + } + } + } } public static class Moving extends BlockContainer { @@ -665,31 +838,19 @@ public static class Moving extends BlockContainer { public Moving() { - super(Material.GLASS); + super(Material.glass); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); this.setHardness(-1.0F); } - public boolean isFullCube(IBlockState state) - { - return false; - } - - /** - * Used to determine ambient occlusion and culling when rebuilding chunks for render - */ - public boolean isOpaqueCube(IBlockState state) - { - return false; - } @SideOnly(Side.CLIENT) - public BlockRenderLayer getBlockLayer() + public EnumWorldBlockLayer getBlockLayer() { - return BlockRenderLayer.CUTOUT_MIPPED; + return EnumWorldBlockLayer.CUTOUT_MIPPED; } @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) + public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side) { - return blockAccess.getBlockState(pos).getBlock() == this ? false : super.shouldSideBeRendered(blockState, blockAccess, pos, side); + return worldIn.getBlockState(pos).getBlock() == this ? false : super.shouldSideBeRendered(worldIn, pos, side); } /** * Returns a new instance of a block's tile entity class. Called on placing the block. @@ -795,7 +956,7 @@ public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState s * @param start The start vector * @param end The end vector */ - public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) + public MovingObjectPosition collisionRayTrace(World worldIn, BlockPos pos, Vec3 start, Vec3 end) { return null; } @@ -811,18 +972,120 @@ public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state } } - public AxisAlignedBB getSelectedBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) - { - TileEntityPFDoor tileentitypiston = this.getTileEntity(worldIn, pos); - return tileentitypiston == null ? null : tileentitypiston.func_184321_a(worldIn, pos); - } + public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) + { + TileEntityPFDoor tileentitypiston = this.getTileEntity(worldIn, pos); + + if (tileentitypiston == null) + { + return null; + } + else + { + float f = tileentitypiston.getProgress(0.0F); + + if (tileentitypiston.isExtending()) + { + f = 1.0F - f; + } + + return this.getBoundingBox(worldIn, pos, tileentitypiston.getPistonState(), f, tileentitypiston.getFacing()); + } + } + + public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) + { + TileEntityPFDoor tileentitypiston = this.getTileEntity(worldIn, pos); + + if (tileentitypiston != null) + { + IBlockState iblockstate = tileentitypiston.getPistonState(); + Block block = iblockstate.getBlock(); + + if (block == this || block.getMaterial() == Material.air) + { + return; + } + + float f = tileentitypiston.getProgress(0.0F); + + if (tileentitypiston.isExtending()) + { + f = 1.0F - f; + } + + block.setBlockBoundsBasedOnState(worldIn, pos); + + if (block == RPBlocks.platform_door_base) + { + f = 0.0F; + } + + EnumFacing enumfacing = tileentitypiston.getFacing(); + this.minX = block.getBlockBoundsMinX() - (double)((float)enumfacing.getFrontOffsetX() * f); + this.minY = block.getBlockBoundsMinY() - (double)((float)enumfacing.getFrontOffsetY() * f); + this.minZ = block.getBlockBoundsMinZ() - (double)((float)enumfacing.getFrontOffsetZ() * f); + this.maxX = block.getBlockBoundsMaxX() - (double)((float)enumfacing.getFrontOffsetX() * f); + this.maxY = block.getBlockBoundsMaxY() - (double)((float)enumfacing.getFrontOffsetY() * f); + this.maxZ = block.getBlockBoundsMaxZ() - (double)((float)enumfacing.getFrontOffsetZ() * f); + } + } + + public AxisAlignedBB getBoundingBox(World worldIn, BlockPos pos, IBlockState extendingBlock, float progress, EnumFacing direction) + { + if (extendingBlock.getBlock() != this && extendingBlock.getBlock().getMaterial() != Material.air) + { + AxisAlignedBB axisalignedbb = extendingBlock.getBlock().getCollisionBoundingBox(worldIn, pos, extendingBlock); + + if (axisalignedbb == null) + { + return null; + } + else + { + double d0 = axisalignedbb.minX; + double d1 = axisalignedbb.minY; + double d2 = axisalignedbb.minZ; + double d3 = axisalignedbb.maxX; + double d4 = axisalignedbb.maxY; + double d5 = axisalignedbb.maxZ; + + if (direction.getFrontOffsetX() < 0) + { + d0 -= (double)((float)direction.getFrontOffsetX() * progress); + } + else + { + d3 -= (double)((float)direction.getFrontOffsetX() * progress); + } + + if (direction.getFrontOffsetY() < 0) + { + d1 -= (double)((float)direction.getFrontOffsetY() * progress); + } + else + { + d4 -= (double)((float)direction.getFrontOffsetY() * progress); + } + + if (direction.getFrontOffsetZ() < 0) + { + d2 -= (double)((float)direction.getFrontOffsetZ() * progress); + } + else + { + d5 -= (double)((float)direction.getFrontOffsetZ() * progress); + } + + return new AxisAlignedBB(d0, d1, d2, d3, d4, d5); + } + } + else + { + return null; + } + } - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { - TileEntityPFDoor tileentitypiston = this.getTileEntity(source, pos); - return tileentitypiston != null ? tileentitypiston.func_184321_a(source, pos) : FULL_BLOCK_AABB; - } - private TileEntityPFDoor getTileEntity(IBlockAccess worldIn, BlockPos pos) { TileEntity tileentity = worldIn.getTileEntity(pos); @@ -853,9 +1116,9 @@ public int getMetaFromState(IBlockState state) return i; } - protected BlockStateContainer createBlockState() + protected BlockState createBlockState() { - return new BlockStateContainer(this, new IProperty[] {FACING}); + return new BlockState(this, new IProperty[] {FACING}); } @Override diff --git a/src/main/java/io/github/cvronmin/railwayp/block/BlockPlatformGlass.java b/src/main/java/io/github/cvronmin/railwayp/block/BlockPlatformGlass.java index d82d177..34e4d19 100644 --- a/src/main/java/io/github/cvronmin/railwayp/block/BlockPlatformGlass.java +++ b/src/main/java/io/github/cvronmin/railwayp/block/BlockPlatformGlass.java @@ -1,26 +1,21 @@ package io.github.cvronmin.railwayp.block; import java.util.List; -import java.util.Random; -import io.github.cvronmin.railwayp.init.RPBlocks; import net.minecraft.block.Block; import net.minecraft.block.BlockPane; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; -import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; +import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -31,148 +26,160 @@ public class BlockPlatformGlass extends Block{ public static final PropertyBool EAST = PropertyBool.create("east"); public static final PropertyBool SOUTH = PropertyBool.create("south"); public static final PropertyBool WEST = PropertyBool.create("west"); - protected static final AxisAlignedBB[] field_185730_f = new AxisAlignedBB[] { - new AxisAlignedBB(0.4D, 0.0D, 0.4D, 0.6D, 1.0D, 0.6D), - new AxisAlignedBB(0.4D, 0.0D, 0.4D, 0.6D, 1.0D, 1.0D), - new AxisAlignedBB(0.0D, 0.0D, 0.4D, 0.6D, 1.0D, 0.6D), - new AxisAlignedBB(0.0D, 0.0D, 0.4D, 0.6D, 1.0D, 1.0D), - new AxisAlignedBB(0.4D, 0.0D, 0.0D, 0.6D, 1.0D, 0.6D), - new AxisAlignedBB(0.4D, 0.0D, 0.0D, 0.6D, 1.0D, 1.0D), - new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.6D, 1.0D, 0.6D), - new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.6D, 1.0D, 1.0D), - new AxisAlignedBB(0.4D, 0.0D, 0.4D, 1.0D, 1.0D, 0.6D), - new AxisAlignedBB(0.4D, 0.0D, 0.4D, 1.0D, 1.0D, 1.0D), - new AxisAlignedBB(0.0D, 0.0D, 0.4D, 1.0D, 1.0D, 0.6D), - new AxisAlignedBB(0.0D, 0.0D, 0.4D, 1.0D, 1.0D, 1.0D), - new AxisAlignedBB(0.4D, 0.0D, 0.0D, 1.0D, 1.0D, 0.6D), - new AxisAlignedBB(0.4D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D), - new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.6D), - new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D) - }; - public BlockPlatformGlass() - { - super(Material.GLASS); +// private boolean neighborDoor; + public BlockPlatformGlass() { + super(Material.glass); this.setDefaultState(this.blockState.getBaseState().withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false))); - this.setCreativeTab(CreativeTabs.DECORATIONS); + this.setCreativeTab(CreativeTabs.tabDecorations); + } +/* public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) + { + if (!worldIn.isRemote) + { + if(neighborBlock == RPBlocks.platform_door_base){ + neighborDoor = true; + } + if(neighborDoor && neighborBlock != RPBlocks.platform_door_base){ + neighborDoor = true; + } + } + }*/ + public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) + { + return state.withProperty(NORTH, canPaneConnectTo(worldIn, pos, EnumFacing.NORTH)) + .withProperty(SOUTH, canPaneConnectTo(worldIn, pos, EnumFacing.SOUTH)) + .withProperty(WEST, canPaneConnectTo(worldIn, pos, EnumFacing.WEST)) + .withProperty(EAST, canPaneConnectTo(worldIn, pos, EnumFacing.EAST)); + } + public boolean isOpaqueCube() + { + return false; } - public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB p_185477_4_, List p_185477_5_, Entity p_185477_6_) + public boolean isFullCube() { - state = this.getActualState(state, worldIn, pos); - addCollisionBoxToList(pos, p_185477_4_, p_185477_5_, field_185730_f[0]); + return false; + } - if (((Boolean)state.getValue(NORTH)).booleanValue()) + public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) + { + boolean flag = this.canPaneConnectTo(worldIn, pos, EnumFacing.NORTH); + boolean flag1 = this.canPaneConnectTo(worldIn, pos, EnumFacing.SOUTH); + boolean flag2 = this.canPaneConnectTo(worldIn, pos, EnumFacing.WEST); + boolean flag3 = this.canPaneConnectTo(worldIn, pos, EnumFacing.EAST); + + if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1)) { - addCollisionBoxToList(pos, p_185477_4_, p_185477_5_, field_185730_f[getBoundingBoxIndex(EnumFacing.NORTH)]); + if (flag2) + { + this.setBlockBounds(0.0F, 0.0F, 0.4f, 0.5F, 1.0F, 0.6f); + super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity); + } + else if (flag3) + { + this.setBlockBounds(0.5F, 0.0F, 0.4f, 1.0F, 1.0F, 0.6f); + super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity); + } } - - if (((Boolean)state.getValue(SOUTH)).booleanValue()) + else { - addCollisionBoxToList(pos, p_185477_4_, p_185477_5_, field_185730_f[getBoundingBoxIndex(EnumFacing.SOUTH)]); + this.setBlockBounds(0.0F, 0.0F, 0.4F, 1.0F, 1.0F, 0.6F); + super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity); } - if (((Boolean)state.getValue(EAST)).booleanValue()) + if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1)) { - addCollisionBoxToList(pos, p_185477_4_, p_185477_5_, field_185730_f[getBoundingBoxIndex(EnumFacing.EAST)]); + if (flag) + { + this.setBlockBounds(0.4F, 0.0F, 0.0F, 0.6F, 1.0F, 0.5F); + super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity); + } + else if (flag1) + { + this.setBlockBounds(0.4F, 0.0F, 0.5F, 0.6F, 1.0F, 1.0F); + super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity); + } } - - if (((Boolean)state.getValue(WEST)).booleanValue()) + else { - addCollisionBoxToList(pos, p_185477_4_, p_185477_5_, field_185730_f[getBoundingBoxIndex(EnumFacing.WEST)]); + this.setBlockBounds(0.4F, 0.0F, 0.0F, 0.6F, 1.0F, 1.0F); + super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity); } } - private static int getBoundingBoxIndex(EnumFacing p_185729_0_) + public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) { - return 1 << p_185729_0_.getHorizontalIndex(); - } - - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { - state = this.getActualState(state, source, pos); - return field_185730_f[getBoundingBoxIndex(state)]; - } - - private static int getBoundingBoxIndex(IBlockState p_185728_0_) - { - int i = 0; + float f = 0.4F; + float f1 = 0.6F; + float f2 = 0.4F; + float f3 = 0.6F; + boolean flag = this.canConnectToBlock(worldIn.getBlockState(pos.north()).getBlock()); + boolean flag1 = this.canConnectToBlock(worldIn.getBlockState(pos.south()).getBlock()); + boolean flag2 = this.canConnectToBlock(worldIn.getBlockState(pos.west()).getBlock()); + boolean flag3 = this.canConnectToBlock(worldIn.getBlockState(pos.east()).getBlock()); - if (((Boolean)p_185728_0_.getValue(NORTH)).booleanValue()) + if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1)) { - i |= getBoundingBoxIndex(EnumFacing.NORTH); + if (flag2) + { + f = 0.0F; + } + else if (flag3) + { + f1 = 1.0F; + } } - - if (((Boolean)p_185728_0_.getValue(EAST)).booleanValue()) + else { - i |= getBoundingBoxIndex(EnumFacing.EAST); + f = 0.0F; + f1 = 1.0F; } - if (((Boolean)p_185728_0_.getValue(SOUTH)).booleanValue()) + if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1)) { - i |= getBoundingBoxIndex(EnumFacing.SOUTH); + if (flag) + { + f2 = 0.0F; + } + else if (flag1) + { + f3 = 1.0F; + } } - - if (((Boolean)p_185728_0_.getValue(WEST)).booleanValue()) + else { - i |= getBoundingBoxIndex(EnumFacing.WEST); + f2 = 0.0F; + f3 = 1.0F; } - return i; + this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3); } - /** - * Get the actual Block state of this Block at the given position. This applies properties not visible in the - * metadata, such as fence connections. - */ - public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) - { - return state.withProperty(NORTH, canPaneConnectTo(worldIn, pos, EnumFacing.NORTH)) - .withProperty(SOUTH, canPaneConnectTo(worldIn, pos, EnumFacing.SOUTH)) - .withProperty(WEST, canPaneConnectTo(worldIn, pos, EnumFacing.WEST)) - .withProperty(EAST, canPaneConnectTo(worldIn, pos, EnumFacing.EAST)); - } - - /** - * Get the Item that this Block should drop when harvested. - */ - public Item getItemDropped(IBlockState state, Random rand, int fortune) - { - return super.getItemDropped(state, rand, fortune); - } - - /** - * Used to determine ambient occlusion and culling when rebuilding chunks for render - */ - public boolean isOpaqueCube(IBlockState state) - { - return false; - } - - public boolean isFullCube(IBlockState state) + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side) { - return false; + return worldIn.getBlockState(pos).getBlock() == this ? false : (worldIn.getBlockState(pos).getBlock() instanceof BlockPlatformDoor.Base ? false : super.shouldSideBeRendered(worldIn, pos, side)); } - public final boolean canPaneConnectToBlock(Block blockIn) + public boolean canPaneConnectTo(IBlockAccess world, BlockPos pos, EnumFacing dir) { - return blockIn.getDefaultState().isFullCube() || blockIn == this || blockIn == Blocks.GLASS || blockIn == Blocks.STAINED_GLASS || blockIn == Blocks.STAINED_GLASS_PANE || blockIn instanceof BlockPane || blockIn == RPBlocks.platform_door_base || blockIn == RPBlocks.platform_door_extension || blockIn == RPBlocks.platform_door_head; + BlockPos off = pos.offset(dir); + Block block = world.getBlockState(off).getBlock(); + return canConnectToBlock(block) || block.isSideSolid(world, off, dir.getOpposite()); } - - @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) + public final boolean canConnectToBlock(Block blockIn) { - return blockAccess.getBlockState(pos.offset(side)).getBlock() == this ? false : super.shouldSideBeRendered(blockState, blockAccess, pos, side); + return blockIn.isFullBlock() || blockIn == this || blockIn == Blocks.glass || blockIn == Blocks.stained_glass || blockIn == Blocks.stained_glass_pane || blockIn instanceof BlockPane || blockIn instanceof BlockPlatformDoor.Base; } - protected boolean canSilkHarvest() { return true; } @SideOnly(Side.CLIENT) - public BlockRenderLayer getBlockLayer() + public EnumWorldBlockLayer getBlockLayer() { - return BlockRenderLayer.CUTOUT_MIPPED; + return EnumWorldBlockLayer.CUTOUT_MIPPED; } /** @@ -182,52 +189,9 @@ public int getMetaFromState(IBlockState state) { return 0; } - - /** - * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed - * blockstate. - */ - public IBlockState withRotation(IBlockState state, Rotation rot) - { - switch (rot) - { - case CLOCKWISE_180: - return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(EAST, state.getValue(WEST)).withProperty(SOUTH, state.getValue(NORTH)).withProperty(WEST, state.getValue(EAST)); - case COUNTERCLOCKWISE_90: - return state.withProperty(NORTH, state.getValue(EAST)).withProperty(EAST, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(WEST)).withProperty(WEST, state.getValue(NORTH)); - case CLOCKWISE_90: - return state.withProperty(NORTH, state.getValue(WEST)).withProperty(EAST, state.getValue(NORTH)).withProperty(SOUTH, state.getValue(EAST)).withProperty(WEST, state.getValue(SOUTH)); - default: - return state; - } - } - - /** - * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed - * blockstate. - */ - public IBlockState withMirror(IBlockState state, Mirror mirrorIn) - { - switch (mirrorIn) - { - case LEFT_RIGHT: - return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(NORTH)); - case FRONT_BACK: - return state.withProperty(EAST, state.getValue(WEST)).withProperty(WEST, state.getValue(EAST)); - default: - return super.withMirror(state, mirrorIn); - } - } - - protected BlockStateContainer createBlockState() + + protected BlockState createBlockState() { - return new BlockStateContainer(this, new IProperty[] {NORTH, EAST, WEST, SOUTH}); - } - - public boolean canPaneConnectTo(IBlockAccess world, BlockPos pos, EnumFacing dir) - { - BlockPos off = pos.offset(dir); - IBlockState state = world.getBlockState(off); - return canPaneConnectToBlock(state.getBlock()) || state.isSideSolid(world, off, dir.getOpposite()); + return new BlockState(this, new IProperty[] {NORTH, EAST, WEST, SOUTH}); } } diff --git a/src/main/java/io/github/cvronmin/railwayp/block/BlockRColorful.java b/src/main/java/io/github/cvronmin/railwayp/block/BlockRColorful.java index d7e043c..bbc4564 100644 --- a/src/main/java/io/github/cvronmin/railwayp/block/BlockRColorful.java +++ b/src/main/java/io/github/cvronmin/railwayp/block/BlockRColorful.java @@ -7,7 +7,7 @@ import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumDyeColor; @@ -18,18 +18,17 @@ public class BlockRColorful extends Block { - public static final PropertyEnum COLOR = PropertyEnum.create("color", EnumDyeColor.class); + public static final PropertyEnum COLOR = PropertyEnum.create("color", EnumDyeColor.class); public BlockRColorful(Material materialIn) { super(materialIn); this.setDefaultState(this.blockState.getBaseState().withProperty(COLOR, EnumDyeColor.WHITE)); - this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS); + this.setCreativeTab(CreativeTabs.tabBlock); } /** - * Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It - * returns the metadata of the dropped item based on the old metadata of the block. + * Get the damage value that this Block should drop */ public int damageDropped(IBlockState state) { @@ -40,10 +39,14 @@ public int damageDropped(IBlockState state) * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @SideOnly(Side.CLIENT) - public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) + public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { - for (EnumDyeColor enumdyecolor : EnumDyeColor.values()) + EnumDyeColor[] aenumdyecolor = EnumDyeColor.values(); + int i = aenumdyecolor.length; + + for (int j = 0; j < i; ++j) { + EnumDyeColor enumdyecolor = aenumdyecolor[j]; list.add(new ItemStack(itemIn, 1, enumdyecolor.getMetadata())); } } @@ -72,8 +75,8 @@ public int getMetaFromState(IBlockState state) return ((EnumDyeColor)state.getValue(COLOR)).getMetadata(); } - protected BlockStateContainer createBlockState() + protected BlockState createBlockState() { - return new BlockStateContainer(this, new IProperty[] {COLOR}); + return new BlockState(this, new IProperty[] {COLOR}); } } \ No newline at end of file diff --git a/src/main/java/io/github/cvronmin/railwayp/block/BlockRailNoticer.java b/src/main/java/io/github/cvronmin/railwayp/block/BlockRailNoticer.java index 7692fb7..ed50235 100644 --- a/src/main/java/io/github/cvronmin/railwayp/block/BlockRailNoticer.java +++ b/src/main/java/io/github/cvronmin/railwayp/block/BlockRailNoticer.java @@ -7,31 +7,34 @@ import io.github.cvronmin.railwayp.tileentity.TileEntityRailNoticer; import net.minecraft.block.BlockRailBase; +import net.minecraft.block.BlockRailBase.EnumRailDirection; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockRailNoticer extends BlockRailBase implements ITileEntityProvider{ - public static final PropertyEnum SHAPE = PropertyEnum.create("shape", BlockRailBase.EnumRailDirection.class, new Predicate() + public static final PropertyEnum SHAPE = PropertyEnum.create("shape", BlockRailBase.EnumRailDirection.class, new Predicate() { - public boolean apply(BlockRailBase.EnumRailDirection p_apply_1_) + public boolean apply(BlockRailBase.EnumRailDirection direction) { - return p_apply_1_ != BlockRailBase.EnumRailDirection.NORTH_EAST && p_apply_1_ != BlockRailBase.EnumRailDirection.NORTH_WEST && p_apply_1_ != BlockRailBase.EnumRailDirection.SOUTH_EAST && p_apply_1_ != BlockRailBase.EnumRailDirection.SOUTH_WEST; + return direction != BlockRailBase.EnumRailDirection.NORTH_EAST && direction != BlockRailBase.EnumRailDirection.NORTH_WEST && direction != BlockRailBase.EnumRailDirection.SOUTH_EAST && direction != BlockRailBase.EnumRailDirection.SOUTH_WEST; + } + public boolean apply(Object p_apply_1_) + { + return this.apply((BlockRailBase.EnumRailDirection)p_apply_1_); } }); public static final PropertyBool POWERED = PropertyBool.create("powered"); @@ -101,7 +104,7 @@ private void updatePoweredState(World worldIn, BlockPos pos, IBlockState state) { boolean flag = ((Boolean)state.getValue(POWERED)).booleanValue(); boolean flag1 = false; - List list = this.findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[0]); + List list = this.findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[0]); if (!list.isEmpty()) { @@ -127,7 +130,7 @@ private void updatePoweredState(World worldIn, BlockPos pos, IBlockState state) if (flag1) { - worldIn.scheduleUpdate(new BlockPos(pos), this, this.tickRate(worldIn)); + worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn)); } // worldIn.updateComparatorOutputLevel(pos, this); @@ -139,7 +142,7 @@ public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) this.updatePoweredState(worldIn, pos, state); } - public IProperty getShapeProperty() + public IProperty getShapeProperty() { return SHAPE; } @@ -171,7 +174,7 @@ public IProperty getShapeProperty() return 0; }*/ - protected List findMinecarts(World worldIn, BlockPos pos, Class clazz, Predicate... filter) + protected List findMinecarts(World worldIn, BlockPos pos, Class clazz, Predicate ... filter) { AxisAlignedBB axisalignedbb = this.getDectectionBox(pos); return filter.length != 1 ? worldIn.getEntitiesWithinAABB(clazz, axisalignedbb) : worldIn.getEntitiesWithinAABB(clazz, axisalignedbb, filter[0]); @@ -206,19 +209,18 @@ public int getMetaFromState(IBlockState state) return i; } - public void onMinecartPass(World world, net.minecraft.entity.item.EntityMinecart cart, BlockPos pos) { TileEntity te = world.getTileEntity(pos); - Entity eti = cart.getRidingEntity(); + Entity eti = cart.riddenByEntity; if(readyupdate && te instanceof TileEntityRailNoticer && eti != null && eti instanceof EntityPlayerMP){ ((TileEntityRailNoticer)te).sendNotice((EntityPlayerMP) eti); // readyupdate = false; } } - protected BlockStateContainer createBlockState() + protected BlockState createBlockState() { - return new BlockStateContainer(this, new IProperty[] {SHAPE, POWERED}); + return new BlockState(this, new IProperty[] {SHAPE, POWERED}); } @Override @@ -230,150 +232,7 @@ public void breakBlock(World worldIn, BlockPos pos, IBlockState state) super.breakBlock(worldIn, pos, state); worldIn.removeTileEntity(pos); } - /** - * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed - * blockstate. - */ - @SuppressWarnings("incomplete-switch") - public IBlockState withRotation(IBlockState state, Rotation rot) - { - switch (rot) - { - case CLOCKWISE_180: - - switch ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)) - { - case ASCENDING_EAST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST); - case ASCENDING_WEST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST); - case ASCENDING_NORTH: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH); - case ASCENDING_SOUTH: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH); - case SOUTH_EAST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); - case SOUTH_WEST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); - case NORTH_WEST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); - case NORTH_EAST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); - } - - case COUNTERCLOCKWISE_90: - - switch ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)) - { - case ASCENDING_EAST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH); - case ASCENDING_WEST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH); - case ASCENDING_NORTH: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST); - case ASCENDING_SOUTH: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST); - case SOUTH_EAST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); - case SOUTH_WEST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); - case NORTH_WEST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); - case NORTH_EAST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); - case NORTH_SOUTH: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.EAST_WEST); - case EAST_WEST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH); - } - - case CLOCKWISE_90: - - switch ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)) - { - case ASCENDING_EAST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH); - case ASCENDING_WEST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH); - case ASCENDING_NORTH: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST); - case ASCENDING_SOUTH: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST); - case SOUTH_EAST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); - case SOUTH_WEST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); - case NORTH_WEST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); - case NORTH_EAST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); - case NORTH_SOUTH: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.EAST_WEST); - case EAST_WEST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH); - } - - default: - return state; - } - } - /** - * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed - * blockstate. - */ - @SuppressWarnings("incomplete-switch") - public IBlockState withMirror(IBlockState state, Mirror mirrorIn) - { - BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)state.getValue(SHAPE); - - switch (mirrorIn) - { - case LEFT_RIGHT: - - switch (blockrailbase$enumraildirection) - { - case ASCENDING_NORTH: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH); - case ASCENDING_SOUTH: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH); - case SOUTH_EAST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); - case SOUTH_WEST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); - case NORTH_WEST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); - case NORTH_EAST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); - default: - return super.withMirror(state, mirrorIn); - } - - case FRONT_BACK: - - switch (blockrailbase$enumraildirection) - { - case ASCENDING_EAST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST); - case ASCENDING_WEST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST); - case ASCENDING_NORTH: - case ASCENDING_SOUTH: - default: - break; - case SOUTH_EAST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); - case SOUTH_WEST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); - case NORTH_WEST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); - case NORTH_EAST: - return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); - } - } - - return super.withMirror(state, mirrorIn); - } /** * Called on both Client and Server when World#addBlockEvent is called */ diff --git a/src/main/java/io/github/cvronmin/railwayp/block/BlockRouteSignage.java b/src/main/java/io/github/cvronmin/railwayp/block/BlockRouteSignage.java index 514d8f8..26023be 100644 --- a/src/main/java/io/github/cvronmin/railwayp/block/BlockRouteSignage.java +++ b/src/main/java/io/github/cvronmin/railwayp/block/BlockRouteSignage.java @@ -10,17 +10,16 @@ import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyInteger; -import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumBlockRenderType; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -33,14 +32,25 @@ public class BlockRouteSignage extends BlockContainer protected BlockRouteSignage() { - super(Material.WOOD); + super(Material.wood); + float f = 0.25F; + float f1 = 1.0F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); } - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) + public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) { - return NULL_AABB; + return null; } - public boolean isFullCube(IBlockState state) + + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos) + { + this.setBlockBoundsBasedOnState(worldIn, pos); + return super.getSelectedBoundingBox(worldIn, pos); + } + + public boolean isFullCube() { return false; } @@ -49,27 +59,12 @@ public boolean isPassable(IBlockAccess worldIn, BlockPos pos) { return true; } - /** - * The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render - */ - public EnumBlockRenderType getRenderType(IBlockState state) - { - return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; - } - /** - * Used to determine ambient occlusion and culling when rebuilding chunks for render - */ - public boolean isOpaqueCube(IBlockState state) + + public boolean isOpaqueCube() { return false; } - /** - * Return true if an entity can be spawned inside the block (used to get the player's bed spawn location) - */ - public boolean canSpawnInBlock() - { - return true; - } + /** * Returns a new instance of a block's tile entity class. Called on placing the block. */ @@ -116,7 +111,8 @@ public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState s } } - public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te, ItemStack stack) { + public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te) + { if (te instanceof TileEntityRouteSignage) { ItemStack itemstack = new ItemStack(RPItems.route_sign, 1); @@ -131,7 +127,7 @@ public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBloc } else { - super.harvestBlock(worldIn, player, pos, state, (TileEntity)null, stack); + super.harvestBlock(worldIn, player, pos, state, (TileEntity)null); } } @@ -150,25 +146,35 @@ public BlockBannerHanging() this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); } - protected static final AxisAlignedBB NORTH_AABB = new AxisAlignedBB(0.0D, 0.109375, 0.875D, 1.0D, 0.890625, 1.0D); - protected static final AxisAlignedBB SOUTH_AABB = new AxisAlignedBB(0.0D, 0.109375f, 0.0D, 1.0D, 0.890625f, 0.125D); - protected static final AxisAlignedBB WEST_AABB = new AxisAlignedBB(0.875, 0.109375f, 0.0D, 1.0D, 0.890625f, 1.0D); - protected static final AxisAlignedBB EAST_AABB = new AxisAlignedBB(0.0D, 0.109375f, 0.0D, 0.125D, 0.890625f, 1.0D); - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) + public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) { - switch ((EnumFacing)state.getValue(FACING)) + EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING); + float f = 0.0F; + f=0.109375f; + float f1 = 0.78125F; + f1=0.890625f; + float f2 = 0.0F; + float f3 = 1.0F; + float f4 = 0.125F; + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + + switch (BlockRouteSignage.SwitchEnumFacing.FACING_LOOKUP[enumfacing.ordinal()]) { - case NORTH: + case 1: default: - return NORTH_AABB; - case SOUTH: - return SOUTH_AABB; - case WEST: - return WEST_AABB; - case EAST: - return EAST_AABB; + this.setBlockBounds(f2, f, 1.0F - f4, f3, f1, 1.0F); + break; + case 2: + this.setBlockBounds(f2, f, 0.0F, f3, f1, f4); + break; + case 3: + this.setBlockBounds(1.0F - f4, f, f2, 1.0F, f1, f3); + break; + case 4: + this.setBlockBounds(0.0F, f, f2, f4, f1, f3); } } + /** * Called when a neighboring block changes. */ @@ -208,9 +214,53 @@ public int getMetaFromState(IBlockState state) return ((EnumFacing)state.getValue(FACING)).getIndex(); } - protected BlockStateContainer createBlockState() + protected BlockState createBlockState() + { + return new BlockState(this, new IProperty[] {FACING}); + } + } + + static final class SwitchEnumFacing + { + static final int[] FACING_LOOKUP = new int[EnumFacing.values().length]; + + static { - return new BlockStateContainer(this, new IProperty[] {FACING}); + try + { + FACING_LOOKUP[EnumFacing.NORTH.ordinal()] = 1; + } + catch (NoSuchFieldError var4) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.SOUTH.ordinal()] = 2; + } + catch (NoSuchFieldError var3) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.WEST.ordinal()] = 3; + } + catch (NoSuchFieldError var2) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.EAST.ordinal()] = 4; + } + catch (NoSuchFieldError var1) + { + ; + } } } } \ No newline at end of file diff --git a/src/main/java/io/github/cvronmin/railwayp/block/BlockWHPF.java b/src/main/java/io/github/cvronmin/railwayp/block/BlockWHPF.java index a385d6d..860d820 100644 --- a/src/main/java/io/github/cvronmin/railwayp/block/BlockWHPF.java +++ b/src/main/java/io/github/cvronmin/railwayp/block/BlockWHPF.java @@ -10,17 +10,16 @@ import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyInteger; -import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumBlockRenderType; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -28,10 +27,12 @@ public class BlockWHPF extends BlockContainer{ public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); - //public static final PropertyInteger ROTATION = PropertyInteger.create("rotation", 0, 15); + public static final PropertyInteger ROTATION = PropertyInteger.create("rotation", 0, 15); public BlockWHPF() { - super(Material.WOOD); - setLightLevel(1); + super(Material.wood); + float f = 0.25F; + float f1 = 1.0F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); } @Override @@ -39,11 +40,19 @@ public TileEntity createNewTileEntity(World worldIn, int meta) { // TODO Auto-generated method stub return new TileEntityWHPF(); } - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) + public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) { - return NULL_AABB; + return null; } - public boolean isFullCube(IBlockState state) + + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos) + { + this.setBlockBoundsBasedOnState(worldIn, pos); + return super.getSelectedBoundingBox(worldIn, pos); + } + + public boolean isFullCube() { return false; } @@ -52,27 +61,12 @@ public boolean isPassable(IBlockAccess worldIn, BlockPos pos) { return true; } - /** - * The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render - */ - public EnumBlockRenderType getRenderType(IBlockState state) - { - return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; - } - /** - * Used to determine ambient occlusion and culling when rebuilding chunks for render - */ - public boolean isOpaqueCube(IBlockState state) + + public boolean isOpaqueCube() { return false; } - /** - * Return true if an entity can be spawned inside the block (used to get the player's bed spawn location) - */ - public boolean canSpawnInBlock() - { - return true; - } + public Item getItemDropped(IBlockState state, Random rand, int fortune) { return RPItems.whpf; @@ -100,7 +94,8 @@ public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState s } } - public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te, ItemStack stack) { + public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te) + { if (te instanceof TileEntityWHPF) { ItemStack itemstack = new ItemStack(RPItems.whpf, 1); @@ -115,7 +110,7 @@ public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBloc } else { - super.harvestBlock(worldIn, player, pos, state, (TileEntity)null, stack); + super.harvestBlock(worldIn, player, pos, state, (TileEntity)null); } } @@ -134,23 +129,32 @@ public BlockBannerHanging() this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); } - protected static final AxisAlignedBB NORTH_AABB = new AxisAlignedBB(0.0D, 0.109375, 0.875D, 1.0D, 0.890625, 1.0D); - protected static final AxisAlignedBB SOUTH_AABB = new AxisAlignedBB(0.0D, 0.109375f, 0.0D, 1.0D, 0.890625f, 0.125D); - protected static final AxisAlignedBB WEST_AABB = new AxisAlignedBB(0.875, 0.109375f, 0.0D, 1.0D, 0.890625f, 1.0D); - protected static final AxisAlignedBB EAST_AABB = new AxisAlignedBB(0.0D, 0.109375f, 0.0D, 0.125D, 0.890625f, 1.0D); - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) + public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) { - switch ((EnumFacing)state.getValue(FACING)) + EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING); + float f = 0.0F; + f=0.109375f; + float f1 = 0.78125F; + f1=0.890625f; + float f2 = 0.0F; + float f3 = 1.0F; + float f4 = 0.125F; + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + + switch (BlockWHPF.SwitchEnumFacing.FACING_LOOKUP[enumfacing.ordinal()]) { - case NORTH: + case 1: default: - return NORTH_AABB; - case SOUTH: - return SOUTH_AABB; - case WEST: - return WEST_AABB; - case EAST: - return EAST_AABB; + this.setBlockBounds(f2, f, 1.0F - f4, f3, f1, 1.0F); + break; + case 2: + this.setBlockBounds(f2, f, 0.0F, f3, f1, f4); + break; + case 3: + this.setBlockBounds(1.0F - f4, f, f2, 1.0F, f1, f3); + break; + case 4: + this.setBlockBounds(0.0F, f, f2, f4, f1, f3); } } @@ -161,7 +165,7 @@ public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state { EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); - if (!worldIn.getBlockState(pos.offset(enumfacing.getOpposite())).getBlock().getMaterial(state).isSolid()) + if (!worldIn.getBlockState(pos.offset(enumfacing.getOpposite())).getBlock().getMaterial().isSolid()) { this.dropBlockAsItem(worldIn, pos, state, 0); worldIn.setBlockToAir(pos); @@ -193,30 +197,26 @@ public int getMetaFromState(IBlockState state) return ((EnumFacing)state.getValue(FACING)).getIndex(); } - protected BlockStateContainer createBlockState() + protected BlockState createBlockState() { - return new BlockStateContainer(this, new IProperty[] {FACING}); + return new BlockState(this, new IProperty[] {FACING}); } } public static class BlockBannerStanding extends BlockWHPF { - protected static final AxisAlignedBB ROOF_AABB = new AxisAlignedBB(0.25, 0, 0.25, 0.75, 1, 0.75); + public BlockBannerStanding() { - this.disableStats(); //this.setDefaultState(this.blockState.getBaseState().withProperty(ROTATION, Integer.valueOf(0))); } - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { - return ROOF_AABB; - } + /** * Called when a neighboring block changes. */ public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) { - if (!worldIn.getBlockState(pos.up()).getBlock().getMaterial(state).isSolid()) + if (!worldIn.getBlockState(pos.up()).getBlock().getMaterial().isSolid()) { this.dropBlockAsItem(worldIn, pos, state, 0); worldIn.setBlockToAir(pos); @@ -224,27 +224,50 @@ public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state super.onNeighborBlockChange(worldIn, pos, state, neighborBlock); } + } + +static final class SwitchEnumFacing + { + static final int[] FACING_LOOKUP = new int[EnumFacing.values().length]; -// /** -// * Convert the given metadata into a BlockState for this Block -// */ -// public IBlockState getStateFromMeta(int meta) -// { -// return this.getDefaultState().withProperty(ROTATION, Integer.valueOf(meta)); -// } -// -// /** -// * Convert the BlockState into the correct metadata value -// */ -// public int getMetaFromState(IBlockState state) -// { -// return ((Integer)state.getValue(ROTATION)).intValue(); -// } -// -// protected BlockStateContainer createBlockState() -// { -// return new BlockStateContainer(this, new IProperty[] {ROTATION}); -// } + static + { + try + { + FACING_LOOKUP[EnumFacing.NORTH.ordinal()] = 1; + } + catch (NoSuchFieldError var4) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.SOUTH.ordinal()] = 2; + } + catch (NoSuchFieldError var3) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.WEST.ordinal()] = 3; + } + catch (NoSuchFieldError var2) + { + ; + } + + try + { + FACING_LOOKUP[EnumFacing.EAST.ordinal()] = 4; + } + catch (NoSuchFieldError var1) + { + ; + } + } } } diff --git a/src/main/java/io/github/cvronmin/railwayp/block/DoorStructureHelper.java b/src/main/java/io/github/cvronmin/railwayp/block/DoorStructureHelper.java index 73d7109..2342dc8 100644 --- a/src/main/java/io/github/cvronmin/railwayp/block/DoorStructureHelper.java +++ b/src/main/java/io/github/cvronmin/railwayp/block/DoorStructureHelper.java @@ -3,15 +3,14 @@ import java.util.ArrayList; import java.util.List; -import com.google.common.collect.Lists; - import net.minecraft.block.Block; -import net.minecraft.block.material.EnumPushReaction; -import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import com.google.common.collect.Lists; + public class DoorStructureHelper { private final World world; @@ -44,11 +43,11 @@ public boolean canMove() { this.toMove.clear(); this.toDestroy.clear(); - IBlockState state = this.world.getBlockState(this.blockToMove); + Block block = this.world.getBlockState(this.blockToMove).getBlock(); - if (!BlockPlatformDoor.Base.func_185646_a(state, this.world, this.blockToMove, this.moveDirection, false)) + if (!BlockPlatformDoor.Base.canPush(block, this.world, this.blockToMove, this.moveDirection, false)) { - if (state.getMobilityFlag() != EnumPushReaction.DESTROY) + if (block.getMobilityFlag() != 1) { return false; } @@ -80,14 +79,13 @@ else if (!this.func_177251_a(this.blockToMove)) private boolean func_177251_a(BlockPos origin) { - IBlockState state = this.world.getBlockState(origin); - Block block = state.getBlock(); + Block block = this.world.getBlockState(origin).getBlock(); - if (block.isAir(state, world, origin)) + if (block.isAir(world, origin)) { return true; } - else if (!BlockPlatformDoor.Base.func_185646_a(state, this.world, origin, this.moveDirection, false)) + else if (!BlockPlatformDoor.Base.canPush(block, this.world, origin, this.moveDirection, false)) { return true; } @@ -141,20 +139,20 @@ else if (this.toMove.contains(origin)) return true; } - state = this.world.getBlockState(blockpos2); - block = state.getBlock(); - if (block.isAir(state, world, blockpos2)) + block = this.world.getBlockState(blockpos2).getBlock(); + + if (block.isAir(world, blockpos2)) { return true; } - if (!BlockPlatformDoor.Base.func_185646_a(state, this.world, blockpos2, this.moveDirection, true) || blockpos2.equals(this.pistonPos)) + if (!BlockPlatformDoor.Base.canPush(block, this.world, blockpos2, this.moveDirection, true) || blockpos2.equals(this.pistonPos)) { return false; } - if (block.getMobilityFlag(state) == EnumPushReaction.DESTROY) + if (block.getMobilityFlag() == 1) { this.toDestroy.add(blockpos2); return true; diff --git a/src/main/java/io/github/cvronmin/railwayp/client/ClientProxy.java b/src/main/java/io/github/cvronmin/railwayp/client/ClientProxy.java index 14ab731..52a0ca4 100644 --- a/src/main/java/io/github/cvronmin/railwayp/client/ClientProxy.java +++ b/src/main/java/io/github/cvronmin/railwayp/client/ClientProxy.java @@ -18,6 +18,10 @@ import io.github.cvronmin.railwayp.tileentity.TileEntityPlatformBanner; import io.github.cvronmin.railwayp.tileentity.TileEntityRouteSignage; import io.github.cvronmin.railwayp.tileentity.TileEntityWHPF; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.item.Item; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.FMLClientHandler; @@ -61,6 +65,18 @@ public void init(FMLInitializationEvent event) { } @SubscribeEvent public void onModelBake(ModelBakeEvent event){ - event.getModelManager().getBlockModelShapes().registerBuiltInBlocks(RPBlocks.wall_where_pf, RPBlocks.roof_where_pf,RPBlocks.wall_name_banner,RPBlocks.wall_platform_banner,RPBlocks.wall_route_sign,RPBlocks.platform_door_extension); + event.modelManager.getBlockModelShapes().registerBuiltInBlocks(RPBlocks.wall_where_pf, RPBlocks.roof_where_pf,RPBlocks.wall_name_banner,RPBlocks.wall_platform_banner,RPBlocks.wall_route_sign,RPBlocks.platform_door_extension); + } + protected void blockRend(Block block, String registerName){ + Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, + new ModelResourceLocation("railwayp:" + registerName, "inventory")); + } + protected void itemRend(Item item, String registerName){ + Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, + new ModelResourceLocation("railwayp:" + registerName, "inventory")); + } + protected void itemRend(Item item, int damage, String ideniter){ + Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, damage, + new ModelResourceLocation("railwayp:" + ideniter, "inventory")); } } diff --git a/src/main/java/io/github/cvronmin/railwayp/client/gui/GuiNameBannerEditor.java b/src/main/java/io/github/cvronmin/railwayp/client/gui/GuiNameBannerEditor.java index eb04884..acaf69d 100644 --- a/src/main/java/io/github/cvronmin/railwayp/client/gui/GuiNameBannerEditor.java +++ b/src/main/java/io/github/cvronmin/railwayp/client/gui/GuiNameBannerEditor.java @@ -3,7 +3,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.lwjgl.input.Keyboard; @@ -12,31 +11,15 @@ import io.github.cvronmin.railwayp.RailwayP; import io.github.cvronmin.railwayp.network.RPPacket; -import io.github.cvronmin.railwayp.network.RPPacketHandler; import io.github.cvronmin.railwayp.network.RPPacket.EnumRPPacket; import io.github.cvronmin.railwayp.tileentity.TileEntityNameBanner; -import io.github.cvronmin.railwayp.tileentity.TileEntityPlatformBanner; -import io.github.cvronmin.railwayp.util.NTUtil; -import io.netty.buffer.Unpooled; -import net.minecraft.block.Block; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraft.network.play.client.CPacketCustomPayload; -import net.minecraft.server.MinecraftServer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChatAllowedCharacters; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.world.World; -import net.minecraftforge.fml.client.FMLClientHandler; -import net.minecraftforge.fml.common.FMLCommonHandler; public class GuiNameBannerEditor extends GuiScreen { /** Text Field to set NBT SignType **/ @@ -70,7 +53,7 @@ public void initGui() { this.signTypeTextField = new GuiTextField(10, this.fontRendererObj, posX + (-75 / 2 - 95), posY + (-80), 75, 20); this.signTypeTextField.setMaxStringLength(1); - this.signTypeTextField.setValidator(new Predicate() { + this.signTypeTextField.func_175205_a(new Predicate() { @Override public boolean apply(String input) { for(char ch : input.toCharArray()){ diff --git a/src/main/java/io/github/cvronmin/railwayp/client/gui/GuiPen.java b/src/main/java/io/github/cvronmin/railwayp/client/gui/GuiPen.java index 01235b3..234f6a2 100644 --- a/src/main/java/io/github/cvronmin/railwayp/client/gui/GuiPen.java +++ b/src/main/java/io/github/cvronmin/railwayp/client/gui/GuiPen.java @@ -24,19 +24,19 @@ public GuiPen(Minecraft mc) { @SubscribeEvent(priority = EventPriority.HIGHEST) public void eventHandler(RenderGameOverlayEvent event){ EntityPlayer entity = Minecraft.getMinecraft().thePlayer; - int cenX = event.getResolution().getScaledWidth() / 6 / 2, y = event.getResolution().getScaledHeight() / 5 * 2; - if(entity.getRidingEntity() instanceof EntityMinecartEmpty){ - drawRect(0, event.getResolution().getScaledHeight() / 5 * 2, event.getResolution().getScaledWidth() / 6, event.getResolution().getScaledHeight() / 5 * 3, 419430400); + int cenX = event.resolution.getScaledWidth() / 6 / 2, y = event.resolution.getScaledHeight() / 5 * 2; + if(entity.ridingEntity instanceof EntityMinecartEmpty){ + drawRect(0, event.resolution.getScaledHeight() / 5 * 2, event.resolution.getScaledWidth() / 6, event.resolution.getScaledHeight() / 5 * 3, 419430400); String s = I18n.format("gui.railway"); - this.mc.fontRendererObj.drawString(s, cenX - mc.fontRendererObj.getStringWidth(s) / 2, y + event.getResolution().getScaledHeight() / 5 / 10, 0xffffff); + this.mc.fontRendererObj.drawString(s, cenX - mc.fontRendererObj.getStringWidth(s) / 2, y + event.resolution.getScaledHeight() / 5 / 10, 0xffffff); if(thisStation != null && thisStation != ""){ if(nextStation != null && nextStation != ""){ String s1 = thisStation + rt + nextStation; - mc.fontRendererObj.drawString(s1, cenX - mc.fontRendererObj.getStringWidth(s1) / 2, y + event.getResolution().getScaledHeight() / 5 / 10 * 2, 0xffffff); + mc.fontRendererObj.drawString(s1, cenX - mc.fontRendererObj.getStringWidth(s1) / 2, y + event.resolution.getScaledHeight() / 5 / 10 * 2, 0xffffff); } else{ String s1 = pt + thisStation; - mc.fontRendererObj.drawString(s1, cenX - mc.fontRendererObj.getStringWidth(s1) / 2, y + event.getResolution().getScaledHeight() / 5 / 10 * 2, 0xffffff); + mc.fontRendererObj.drawString(s1, cenX - mc.fontRendererObj.getStringWidth(s1) / 2, y + event.resolution.getScaledHeight() / 5 / 10 * 2, 0xffffff); } } } diff --git a/src/main/java/io/github/cvronmin/railwayp/client/gui/GuiPlatformBannerEditor.java b/src/main/java/io/github/cvronmin/railwayp/client/gui/GuiPlatformBannerEditor.java index 5c25674..b2024c4 100644 --- a/src/main/java/io/github/cvronmin/railwayp/client/gui/GuiPlatformBannerEditor.java +++ b/src/main/java/io/github/cvronmin/railwayp/client/gui/GuiPlatformBannerEditor.java @@ -3,7 +3,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.lwjgl.input.Keyboard; @@ -12,30 +11,15 @@ import io.github.cvronmin.railwayp.RailwayP; import io.github.cvronmin.railwayp.network.RPPacket; -import io.github.cvronmin.railwayp.network.RPPacketHandler; import io.github.cvronmin.railwayp.network.RPPacket.EnumRPPacket; import io.github.cvronmin.railwayp.tileentity.TileEntityPlatformBanner; -import io.github.cvronmin.railwayp.util.NTUtil; -import io.netty.buffer.Unpooled; -import net.minecraft.block.Block; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraft.network.play.client.CPacketCustomPayload; -import net.minecraft.server.MinecraftServer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChatAllowedCharacters; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.world.World; -import net.minecraftforge.fml.client.FMLClientHandler; -import net.minecraftforge.fml.common.FMLCommonHandler; public class GuiPlatformBannerEditor extends GuiScreen { /** Text Field to set NBT PlatformNumber **/ @@ -69,7 +53,7 @@ public void initGui() { this.platformTextField = new GuiTextField(10, this.fontRendererObj, posX + (-75 / 2 - 95), posY + (-80), 75, 20); this.platformTextField.setMaxStringLength(1); - this.platformTextField.setValidator(new Predicate() { + this.platformTextField.func_175205_a(new Predicate() { @Override public boolean apply(String input) { for(char ch : input.toCharArray()){ @@ -82,7 +66,7 @@ public boolean apply(String input) { this.directionTextField = new GuiTextField(14, this.fontRendererObj, posX + (-75 / 2), posY + (-80), 75, 20); this.directionTextField.setMaxStringLength(1); - this.directionTextField.setValidator(new Predicate() { + this.directionTextField.func_175205_a(new Predicate() { @Override public boolean apply(String input) { for(char ch : input.toCharArray()){ diff --git a/src/main/java/io/github/cvronmin/railwayp/client/gui/GuiWHPFEditor.java b/src/main/java/io/github/cvronmin/railwayp/client/gui/GuiWHPFEditor.java index d03cee0..17df6e5 100644 --- a/src/main/java/io/github/cvronmin/railwayp/client/gui/GuiWHPFEditor.java +++ b/src/main/java/io/github/cvronmin/railwayp/client/gui/GuiWHPFEditor.java @@ -3,7 +3,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.lwjgl.input.Keyboard; @@ -13,12 +12,8 @@ import io.github.cvronmin.railwayp.RailwayP; import io.github.cvronmin.railwayp.init.RPBlocks; import io.github.cvronmin.railwayp.network.RPPacket; -import io.github.cvronmin.railwayp.network.RPPacketHandler; import io.github.cvronmin.railwayp.network.RPPacket.EnumRPPacket; -import io.github.cvronmin.railwayp.tileentity.TileEntityPlatformBanner; import io.github.cvronmin.railwayp.tileentity.TileEntityWHPF; -import io.github.cvronmin.railwayp.util.NTUtil; -import io.netty.buffer.Unpooled; import net.minecraft.block.Block; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; @@ -26,18 +21,7 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraft.network.play.client.CPacketCustomPayload; -import net.minecraft.server.MinecraftServer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChatAllowedCharacters; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.world.World; -import net.minecraftforge.fml.client.FMLClientHandler; -import net.minecraftforge.fml.common.FMLCommonHandler; public class GuiWHPFEditor extends GuiScreen { /** Text Field to set NBT PlatformNumber **/ @@ -73,7 +57,7 @@ public void initGui() { this.platformTextField = new GuiTextField(10, this.fontRendererObj, posX + (-75 / 2 - 95), posY + (-80), 75, 20); this.platformTextField.setMaxStringLength(1); - this.platformTextField.setValidator(new Predicate() { + this.platformTextField.func_175205_a(new Predicate() { @Override public boolean apply(String input) { for(char ch : input.toCharArray()){ @@ -86,7 +70,7 @@ public boolean apply(String input) { this.directionTextField = new GuiTextField(14, this.fontRendererObj, posX + (-75 / 2), posY + (-80), 75, 20); this.directionTextField.setMaxStringLength(1); - this.directionTextField.setValidator(new Predicate() { + this.directionTextField.func_175205_a(new Predicate() { @Override public boolean apply(String input) { for(char ch : input.toCharArray()){ @@ -99,7 +83,7 @@ public boolean apply(String input) { this.rotationTextField = new GuiTextField(15, this.fontRendererObj, posX + (-75 / 2 - 95), posY + (10), 75, 20); this.rotationTextField.setMaxStringLength(3); - this.rotationTextField.setValidator(new Predicate() { + this.rotationTextField.func_175205_a(new Predicate() { @Override public boolean apply(String input) { for(char ch : input.toCharArray()){ diff --git a/src/main/java/io/github/cvronmin/railwayp/client/model/ModelBlock.java b/src/main/java/io/github/cvronmin/railwayp/client/model/ModelBlock.java index f82d04e..8a4dbcf 100644 --- a/src/main/java/io/github/cvronmin/railwayp/client/model/ModelBlock.java +++ b/src/main/java/io/github/cvronmin/railwayp/client/model/ModelBlock.java @@ -1,18 +1,18 @@ -package io.github.cvronmin.railwayp.client.model; - -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; - -public class ModelBlock extends ModelBase { - public ModelRenderer modelBlock; - public ModelBlock(){ - this.textureWidth = 64; - this.textureHeight = 32; - modelBlock = new ModelRenderer(this, 0, 0); - modelBlock.addBox(-8, -8, -8, 16, 16, 16); - } - public void render(){ - modelBlock.rotationPointY = -0; - modelBlock.render(0.09375f); - } -} +package io.github.cvronmin.railwayp.client.model; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; + +public class ModelBlock extends ModelBase { + public ModelRenderer modelBlock; + public ModelBlock(){ + this.textureWidth = 64; + this.textureHeight = 32; + modelBlock = new ModelRenderer(this, 0, 0); + modelBlock.addBox(-8, -8, -8, 16, 16, 16); + } + public void render(){ + modelBlock.rotationPointY = -0; + modelBlock.render(0.09375f); + } +} diff --git a/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityColorfulRenderer.java b/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityColorfulRenderer.java index 31aafad..1241836 100644 --- a/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityColorfulRenderer.java +++ b/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityColorfulRenderer.java @@ -95,7 +95,7 @@ private ResourceLocation func_178463_a(TileEntityColorful bannerObj) timedbannertexture = new TileEntityColorfulRenderer.TimedBannerTexture(null); timedbannertexture.bannerTexture = new ResourceLocation("railwayp", s); - Minecraft.getMinecraft().getTextureManager().loadTexture(timedbannertexture.bannerTexture, new LayeredCustomColorMaskTexture(bannerObj.getBlockType().getMaterial(bannerObj.getBlockType().getDefaultState()) == Material.ROCK ? MOSAIC_TEXTURES : PLATE_TEXTURES, arraylist, list)); + Minecraft.getMinecraft().getTextureManager().loadTexture(timedbannertexture.bannerTexture, new LayeredCustomColorMaskTexture(bannerObj.getBlockType().getMaterial() == Material.rock ? MOSAIC_TEXTURES : PLATE_TEXTURES, arraylist, list)); DESIGNS.put(s, timedbannertexture); } diff --git a/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityNameBannerRenderer.java b/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityNameBannerRenderer.java index a5977f4..b4f3480 100644 --- a/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityNameBannerRenderer.java +++ b/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityNameBannerRenderer.java @@ -1,7 +1,6 @@ package io.github.cvronmin.railwayp.client.renderer; import java.util.List; -import java.util.Locale; import org.lwjgl.opengl.GL11; @@ -14,19 +13,14 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiUtilRenderComponents; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexFormat; //import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import scala.Tuple1; @SideOnly(Side.CLIENT) public class TileEntityNameBannerRenderer extends TileEntitySpecialRenderer { @@ -40,7 +34,7 @@ public void renderTileEntityAt(TileEntityNameBanner te, double x, double y, doub boolean flag = te.getWorld() != null; int j = flag ? te.getBlockMetadata() : 0; long k = flag ? te.getWorld().getTotalWorldTime() : 0L; - Block block = te.getBlockType(); + //Block block = te.getBlockType(); GlStateManager.pushMatrix(); float f1 = 0.6666667F; float f3; @@ -99,13 +93,13 @@ public void renderTileEntityAt(TileEntityNameBanner te, double x, double y, doub boolean requireHdraw = te.getSignType() == 1 ? true : (te.getSignType() == 2 ? true : false); if (destroyStage < 0) { if (te.signText[0] != null) { - ITextComponent ichatcomponent = te.signText[0]; - List list = GuiUtilRenderComponents.splitText(ichatcomponent, 90, fontrenderer, false, + IChatComponent ichatcomponent = te.signText[0]; + List list = GuiUtilRenderComponents.func_178908_a(ichatcomponent, 90, fontrenderer, false, true); - String s = list != null && list.size() > 0 ? ((ITextComponent) list.get(0)).getFormattedText() : ""; + String s = list != null && list.size() > 0 ? ((IChatComponent) list.get(0)).getFormattedText() : ""; if (requireHdraw){ - String s1 = list != null && list.size() > 0 ? ((ITextComponent) list.get(0)).getUnformattedText() : ""; + String s1 = list != null && list.size() > 0 ? ((IChatComponent) list.get(0)).getUnformattedText() : ""; //System.out.println(fontrenderer.FONT_HEIGHT * s.length()); drawVString(fontrenderer,s1, -fontrenderer.getCharWidth(s.charAt(0)), -fontrenderer.FONT_HEIGHT * s.length(), te.getColor()); @@ -125,10 +119,10 @@ public void renderTileEntityAt(TileEntityNameBanner te, double x, double y, doub GlStateManager.depthMask(false); if (destroyStage < 0) { if (te.signText[1] != null) { - ITextComponent ichatcomponent = te.signText[1]; - List list = GuiUtilRenderComponents.splitText(ichatcomponent, 90, fontrenderer, false, + IChatComponent ichatcomponent = te.signText[1]; + List list = GuiUtilRenderComponents.func_178908_a(ichatcomponent, 90, fontrenderer, false, true); - String s = list != null && list.size() > 0 ? ((ITextComponent) list.get(0)).getFormattedText() : ""; + String s = list != null && list.size() > 0 ? ((IChatComponent) list.get(0)).getFormattedText() : ""; int xxx = fontrenderer.getStringWidth(s); if (xxx > TEXT2_MAX_ALLOW_LENGTH) { GlStateManager.scale(TEXT2_MAX_ALLOW_LENGTH / (float)xxx, 1, 1); diff --git a/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityPFDoorRenderer.java b/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityPFDoorRenderer.java index aed89ce..a76ae72 100644 --- a/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityPFDoorRenderer.java +++ b/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityPFDoorRenderer.java @@ -11,34 +11,34 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.VertexBuffer; +import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.math.BlockPos; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class TileEntityPFDoorRenderer extends TileEntitySpecialRenderer +public class TileEntityPFDoorRenderer extends TileEntitySpecialRenderer { - private BlockRendererDispatcher blockRenderer; + private final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher(); - public void renderTileEntityAt(TileEntityPFDoor te, double x, double y, double z, float partialTicks, int destroyStage) + public void func_178461_a(TileEntityPFDoor piston, double p_178461_2_, double p_178461_4_, double p_178461_6_, float p_178461_8_, int p_178461_9_) { - if(blockRenderer == null) blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher(); - BlockPos blockpos = te.getPos(); - IBlockState iblockstate = te.getPistonState(); + BlockPos blockpos = piston.getPos(); + IBlockState iblockstate = piston.getPistonState(); Block block = iblockstate.getBlock(); - if (iblockstate.getMaterial() != Material.AIR && te.getProgress(partialTicks) < 1.0F) + if (block.getMaterial() != Material.air && piston.getProgress(p_178461_8_) < 1.0F) { Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer vertexbuffer = tessellator.getBuffer(); - this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + this.bindTexture(TextureMap.locationBlocksTexture); RenderHelper.disableStandardItemLighting(); - GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); + GlStateManager.blendFunc(770, 771); GlStateManager.enableBlend(); GlStateManager.disableCull(); @@ -50,37 +50,38 @@ public void renderTileEntityAt(TileEntityPFDoor te, double x, double y, double z { GlStateManager.shadeModel(7424); } - vertexbuffer.begin(7, DefaultVertexFormats.BLOCK); - vertexbuffer.setTranslation((double)((float)x - (float)blockpos.getX() + te.getOffsetX(partialTicks)), (double)((float)y - (float)blockpos.getY() + te.getOffsetY(partialTicks)), (double)((float)z - (float)blockpos.getZ() + te.getOffsetZ(partialTicks))); + + worldrenderer.begin(7, DefaultVertexFormats.BLOCK); + worldrenderer.setTranslation((double)((float)p_178461_2_ - (float)blockpos.getX() + (piston.getOffsetX(p_178461_8_) * 0.5f)), (double)((float)p_178461_4_ - (float)blockpos.getY() + (piston.getOffsetY(p_178461_8_) * 0.5f)), (double)((float)p_178461_6_ - (float)blockpos.getZ() + (piston.getOffsetZ(p_178461_8_) * 0.5f))); World world = this.getWorld(); - if (block == RPBlocks.platform_door_head && te.getProgress(partialTicks) < 0.5F) + if (block == RPBlocks.platform_door_head && piston.getProgress(p_178461_8_) < 0.5F) { iblockstate = iblockstate.withProperty(BlockPlatformDoor.Extension.SHORT, Boolean.valueOf(true)); - this.renderStateModel(blockpos, iblockstate, vertexbuffer, world, true); + this.blockRenderer.getBlockModelRenderer().renderModel(world, this.blockRenderer.getModelFromBlockState(iblockstate, world, blockpos), iblockstate, blockpos, worldrenderer, true); } - else if (te.shouldPistonHeadBeRendered() && !te.isExtending()) + else if (piston.shouldPistonHeadBeRendered() && !piston.isExtending()) { IBlockState iblockstate1 = RPBlocks.platform_door_head.getDefaultState().withProperty(BlockPlatformDoor.Extension.FACING, iblockstate.getValue(BlockPlatformDoor.Base.FACING)); - iblockstate1 = iblockstate1.withProperty(BlockPlatformDoor.Extension.SHORT, Boolean.valueOf(te.getProgress(partialTicks) >= 0.5F)); - this.renderStateModel(blockpos, iblockstate, vertexbuffer, world, true); - vertexbuffer.setTranslation((double)((float)x - (float)blockpos.getX()), (double)((float)y - (float)blockpos.getY()), (double)((float)z - (float)blockpos.getZ())); + iblockstate1 = iblockstate1.withProperty(BlockPlatformDoor.Extension.SHORT, Boolean.valueOf(piston.getProgress(p_178461_8_) >= 0.5F)); + this.blockRenderer.getBlockModelRenderer().renderModel(world, this.blockRenderer.getModelFromBlockState(iblockstate1, world, blockpos), iblockstate1, blockpos, worldrenderer, true); + worldrenderer.setTranslation((double)((float)p_178461_2_ - (float)blockpos.getX()), (double)((float)p_178461_4_ - (float)blockpos.getY()), (double)((float)p_178461_6_ - (float)blockpos.getZ())); iblockstate.withProperty(BlockPlatformDoor.Base.EXTENDED, Boolean.valueOf(true)); - this.renderStateModel(blockpos, iblockstate, vertexbuffer, world, true); - } + this.blockRenderer.getBlockModelRenderer().renderModel(world, this.blockRenderer.getModelFromBlockState(iblockstate, world, blockpos), iblockstate, blockpos, worldrenderer, true); + } else { - this.renderStateModel(blockpos, iblockstate, vertexbuffer, world, false); + this.blockRenderer.getBlockModelRenderer().renderModel(world, this.blockRenderer.getModelFromBlockState(iblockstate, world, blockpos), iblockstate, blockpos, worldrenderer, false); } - vertexbuffer.setTranslation(0.0D, 0.0D, 0.0D); + worldrenderer.setTranslation(0.0D, 0.0D, 0.0D); tessellator.draw(); RenderHelper.enableStandardItemLighting(); } } - private boolean renderStateModel(BlockPos p_188186_1_, IBlockState p_188186_2_, VertexBuffer p_188186_3_, World p_188186_4_, boolean p_188186_5_) + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks, int destroyStage) { - return this.blockRenderer.getBlockModelRenderer().renderModel(p_188186_4_, this.blockRenderer.getModelForState(p_188186_2_), p_188186_2_, p_188186_1_, p_188186_3_, p_188186_5_); + this.func_178461_a((TileEntityPFDoor)te, x, y, z, partialTicks, destroyStage); } } \ No newline at end of file diff --git a/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityPlatformBannerRenderer.java b/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityPlatformBannerRenderer.java index 84de158..a3934da 100644 --- a/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityPlatformBannerRenderer.java +++ b/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityPlatformBannerRenderer.java @@ -1,34 +1,22 @@ package io.github.cvronmin.railwayp.client.renderer; -import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Map; import org.lwjgl.opengl.GL11; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import io.github.cvronmin.railwayp.client.model.ModelPlatformBanner; -import io.github.cvronmin.railwayp.client.renderer.texture.LayeredCustomColorMaskTexture; import io.github.cvronmin.railwayp.client.renderer.texture.UnifedBannerTextures; import io.github.cvronmin.railwayp.init.RPBlocks; -import io.github.cvronmin.railwayp.init.RPItems; -import io.github.cvronmin.railwayp.tileentity.EnumUnifiedBannerPattern; import io.github.cvronmin.railwayp.tileentity.TileEntityPlatformBanner; -import io.github.cvronmin.railwayp.tileentity.TileEntityRouteSignage; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiUtilRenderComponents; -import net.minecraft.client.renderer.BannerTextures; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.init.Blocks; -//import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IChatComponent; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -88,9 +76,9 @@ public void renderTileEntityAt(TileEntityPlatformBanner entityBanner, double x, int xx; if (destroyStages < 0) { if (entityBanner.signText[0] != null) { - ITextComponent ichatcomponent = entityBanner.signText[0]; - List list = GuiUtilRenderComponents.splitText(ichatcomponent, 180, fontrenderer, false, true); - String s = list != null && list.size() > 0 ? ((ITextComponent) list.get(0)).getFormattedText() : ""; + IChatComponent ichatcomponent = entityBanner.signText[0]; + List list = GuiUtilRenderComponents.func_178908_a(ichatcomponent, 180, fontrenderer, false, true); + String s = list != null && list.size() > 0 ? ((IChatComponent) list.get(0)).getFormattedText() : ""; xx = entityBanner.getDirection() == 0 ? 12 : (entityBanner.getDirection() == 2 ? 36 - fontrenderer.getStringWidth(s) : 0); int xxx = fontrenderer.getStringWidth(s); @@ -116,9 +104,9 @@ public void renderTileEntityAt(TileEntityPlatformBanner entityBanner, double x, GlStateManager.depthMask(false); if (destroyStages < 0) { if (entityBanner.signText[1] != null) { - ITextComponent ichatcomponent = entityBanner.signText[1]; - List list = GuiUtilRenderComponents.splitText(ichatcomponent, 90, fontrenderer, false, true); - String s = list != null && list.size() > 0 ? ((ITextComponent) list.get(0)).getFormattedText() : ""; + IChatComponent ichatcomponent = entityBanner.signText[1]; + List list = GuiUtilRenderComponents.func_178908_a(ichatcomponent, 90, fontrenderer, false, true); + String s = list != null && list.size() > 0 ? ((IChatComponent) list.get(0)).getFormattedText() : ""; xx = entityBanner.getDirection() == 0 ? 24 : (entityBanner.getDirection() == 2 ? 72 - fontrenderer.getStringWidth(s) : 0); fontrenderer.drawString(s, xx, 1 * 10 - entityBanner.signText.length * 5, 0); diff --git a/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityRouteSignageRenderer.java b/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityRouteSignageRenderer.java index 5dd995f..b837e6d 100644 --- a/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityRouteSignageRenderer.java +++ b/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityRouteSignageRenderer.java @@ -1,28 +1,21 @@ package io.github.cvronmin.railwayp.client.renderer; -import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Map; import org.lwjgl.opengl.GL11; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import io.github.cvronmin.railwayp.client.model.ModelRouteSignage; -import io.github.cvronmin.railwayp.client.renderer.texture.LayeredCustomColorMaskTexture; import io.github.cvronmin.railwayp.client.renderer.texture.UnifedBannerTextures; import io.github.cvronmin.railwayp.tileentity.TileEntityRouteSignage; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiUtilRenderComponents; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -//import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IChatComponent; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -87,9 +80,9 @@ public void renderTileEntityAt(TileEntityRouteSignage entityBanner, double x, do { if (entityBanner.stationText[0] != null) { - ITextComponent ichatcomponent = entityBanner.stationText[0]; - List list = GuiUtilRenderComponents.splitText(ichatcomponent, 90, fontrenderer, false, true); - String s = list != null && list.size() > 0 ? ((ITextComponent)list.get(0)).getFormattedText() : ""; + IChatComponent ichatcomponent = entityBanner.stationText[0]; + List list = GuiUtilRenderComponents.func_178908_a(ichatcomponent, 90, fontrenderer, false, true); + String s = list != null && list.size() > 0 ? ((IChatComponent)list.get(0)).getFormattedText() : ""; fontrenderer.drawString(s, (float)(-fontrenderer.getStringWidth(s) / 2)/* + 33.333333333f*/ + 2, 0 * 10 - entityBanner.stationText.length * 5, 0, false); } } @@ -104,9 +97,9 @@ public void renderTileEntityAt(TileEntityRouteSignage entityBanner, double x, do { if (entityBanner.stationText[1] != null) { - ITextComponent ichatcomponent = entityBanner.stationText[1]; - List list = GuiUtilRenderComponents.splitText(ichatcomponent, 90, fontrenderer, false, true); - String s = list != null && list.size() > 0 ? ((ITextComponent)list.get(0)).getFormattedText() : ""; + IChatComponent ichatcomponent = entityBanner.stationText[1]; + List list = GuiUtilRenderComponents.func_178908_a(ichatcomponent, 90, fontrenderer, false, true); + String s = list != null && list.size() > 0 ? ((IChatComponent)list.get(0)).getFormattedText() : ""; fontrenderer.drawString(s, (float)(-fontrenderer.getStringWidth(s) / 2)/* + 50*/ + (2 * 1.5f), (float)(1 * 10 - entityBanner.stationText.length * 5), 0, false); } } @@ -126,9 +119,9 @@ public void renderTileEntityAt(TileEntityRouteSignage entityBanner, double x, do { if (entityBanner.nextText[0] != null) { - ITextComponent ichatcomponent = entityBanner.nextText[0]; - List list = GuiUtilRenderComponents.splitText(ichatcomponent, 90, fontrenderer, false, true); - String s = list != null && list.size() > 0 ? ((ITextComponent)list.get(0)).getFormattedText() : ""; + IChatComponent ichatcomponent = entityBanner.nextText[0]; + List list = GuiUtilRenderComponents.func_178908_a(ichatcomponent, 90, fontrenderer, false, true); + String s = list != null && list.size() > 0 ? ((IChatComponent)list.get(0)).getFormattedText() : ""; fontrenderer.drawString(s, (-fontrenderer.getStringWidth(s) / 2) + xx * 0.6666667f, 0 * 10 - entityBanner.nextText.length * 5 + 20 * 0.6666667f, 0, false); } } @@ -143,9 +136,9 @@ public void renderTileEntityAt(TileEntityRouteSignage entityBanner, double x, do { if (entityBanner.nextText[1] != null) { - ITextComponent ichatcomponent = entityBanner.nextText[1]; - List list = GuiUtilRenderComponents.splitText(ichatcomponent, 90, fontrenderer, false, true); - String s = list != null && list.size() > 0 ? ((ITextComponent)list.get(0)).getFormattedText() : ""; + IChatComponent ichatcomponent = entityBanner.nextText[1]; + List list = GuiUtilRenderComponents.func_178908_a(ichatcomponent, 90, fontrenderer, false, true); + String s = list != null && list.size() > 0 ? ((IChatComponent)list.get(0)).getFormattedText() : ""; fontrenderer.drawString(s, (-fontrenderer.getStringWidth(s) / 2) + xx, 1 * 10 - entityBanner.nextText.length * 5 + 20, 0, false); } } @@ -214,7 +207,7 @@ private ResourceLocation func_178463_a(TileEntityRouteSignage bannerObj) timedbannertexture.systemTime = System.currentTimeMillis(); return timedbannertexture.bannerTexture; }*/ - return UnifedBannerTextures.ROUTESIGN_DESIGNS.getResourceLocation(bannerObj.getPatternResourceLocation(), bannerObj.getPatternList(), bannerObj.getColorList()); + return UnifedBannerTextures.ROUTESIGN_DESIGNS.getResourceLocation(bannerObj.func_175116_e(), bannerObj.getPatternList(), bannerObj.getColorList()); } diff --git a/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityWHPFRenderer.java b/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityWHPFRenderer.java index 2909e81..36d0051 100644 --- a/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityWHPFRenderer.java +++ b/src/main/java/io/github/cvronmin/railwayp/client/renderer/TileEntityWHPFRenderer.java @@ -1,28 +1,22 @@ package io.github.cvronmin.railwayp.client.renderer; -import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Map; import org.lwjgl.opengl.GL11; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import io.github.cvronmin.railwayp.client.model.ModelPFSignL; -import io.github.cvronmin.railwayp.client.renderer.texture.LayeredCustomColorMaskTexture; import io.github.cvronmin.railwayp.client.renderer.texture.UnifedBannerTextures; import io.github.cvronmin.railwayp.init.RPBlocks; import io.github.cvronmin.railwayp.tileentity.TileEntityWHPF; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiUtilRenderComponents; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IChatComponent; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -99,9 +93,9 @@ public void renderTileEntityAt(TileEntityWHPF entityBanner, double x, double y, { if (entityBanner.signText[0] != null) { - ITextComponent ichatcomponent = entityBanner.signText[0]; - List list = GuiUtilRenderComponents.splitText(ichatcomponent, 180, fontrenderer, false, true); - String s = list != null && list.size() > 0 ? ((ITextComponent)list.get(0)).getFormattedText() : ""; + IChatComponent ichatcomponent = entityBanner.signText[0]; + List list = GuiUtilRenderComponents.func_178908_a(ichatcomponent, 180, fontrenderer, false, true); + String s = list != null && list.size() > 0 ? ((IChatComponent)list.get(0)).getFormattedText() : ""; xx = entityBanner.getDirection() <= 1 ? 12 + 25 : (entityBanner.getDirection() >= 2 ? 36 + 16 - fontrenderer.getStringWidth(s) : 0); int xxx = fontrenderer.getStringWidth(s); //System.out.println("Text1:" + xxx); @@ -128,9 +122,9 @@ public void renderTileEntityAt(TileEntityWHPF entityBanner, double x, double y, { if (entityBanner.signText[1] != null) { - ITextComponent ichatcomponent = entityBanner.signText[1]; - List list = GuiUtilRenderComponents.splitText(ichatcomponent, 180, fontrenderer, false, true); - String s = list != null && list.size() > 0 ? ((ITextComponent)list.get(0)).getFormattedText() : ""; + IChatComponent ichatcomponent = entityBanner.signText[1]; + List list = GuiUtilRenderComponents.func_178908_a(ichatcomponent, 180, fontrenderer, false, true); + String s = list != null && list.size() > 0 ? ((IChatComponent)list.get(0)).getFormattedText() : ""; xx = entityBanner.getDirection() <= 1 ? 24 + 50 : (entityBanner.getDirection() >= 2 ? 72 + 30 - fontrenderer.getStringWidth(s) : 0); int xxx = fontrenderer.getStringWidth(s); //System.out.println("Text2:"+xxx); @@ -209,7 +203,7 @@ private ResourceLocation func_178463_a(TileEntityWHPF bannerObj) timedbannertexture.systemTime = System.currentTimeMillis(); return timedbannertexture.bannerTexture; }*/ - return UnifedBannerTextures.PFSIGN_DESIGNS.getResourceLocation(bannerObj.getPatternResourceLocation(), bannerObj.getPatternList(), bannerObj.getColorList()); + return UnifedBannerTextures.PFSIGN_DESIGNS.getResourceLocation(bannerObj.func_175116_e(), bannerObj.getPatternList(), bannerObj.getColorList()); } diff --git a/src/main/java/io/github/cvronmin/railwayp/client/renderer/texture/LayeredCustomColorMaskTexture.java b/src/main/java/io/github/cvronmin/railwayp/client/renderer/texture/LayeredCustomColorMaskTexture.java index 663a60c..7bc28d9 100644 --- a/src/main/java/io/github/cvronmin/railwayp/client/renderer/texture/LayeredCustomColorMaskTexture.java +++ b/src/main/java/io/github/cvronmin/railwayp/client/renderer/texture/LayeredCustomColorMaskTexture.java @@ -3,23 +3,20 @@ import java.awt.Graphics; import java.awt.image.BufferedImage; import java.awt.image.ImageObserver; -import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.util.List; -import org.apache.commons.io.IOUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import net.minecraft.block.material.MapColor; import net.minecraft.client.renderer.texture.AbstractTexture; import net.minecraft.client.renderer.texture.TextureUtil; -import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.IResourceManager; import net.minecraft.item.EnumDyeColor; +import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.MathHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -30,9 +27,9 @@ public class LayeredCustomColorMaskTexture extends AbstractTexture { /** The location of the texture. */ private final ResourceLocation textureLocation; private final List textureList; - private final List colorList; + private final List colorList; - public LayeredCustomColorMaskTexture(ResourceLocation textureLocationIn, List p_i46101_2_, List p_i46101_3_) + public LayeredCustomColorMaskTexture(ResourceLocation textureLocationIn, List p_i46101_2_, List p_i46101_3_) { this.textureLocation = textureLocationIn; this.textureList = p_i46101_2_; @@ -42,88 +39,68 @@ public LayeredCustomColorMaskTexture(ResourceLocation textureLocationIn, List p_ public void loadTexture(IResourceManager resourceManager) throws IOException { this.deleteGlTexture(); - IResource iresource = null; BufferedImage bufferedimage; - label6: + + try { - try - { - iresource = resourceManager.getResource(this.textureLocation); - BufferedImage bufferedimage1 = TextureUtil.readBufferedImage(iresource.getInputStream()); - int i = bufferedimage1.getType(); + BufferedImage bufferedimage1 = TextureUtil.readBufferedImage(resourceManager.getResource(this.textureLocation).getInputStream()); + int i = bufferedimage1.getType(); - if (i == 0) - { - i = 6; - } + if (i == 0) + { + i = 6; + } - bufferedimage = new BufferedImage(bufferedimage1.getWidth(), bufferedimage1.getHeight(), i); - Graphics graphics = bufferedimage.getGraphics(); - graphics.drawImage(bufferedimage1, 0, 0, (ImageObserver)null); - int j = 0; + bufferedimage = new BufferedImage(bufferedimage1.getWidth(), bufferedimage1.getHeight(), i); + Graphics graphics = bufferedimage.getGraphics(); + graphics.drawImage(bufferedimage1, 0, 0, (ImageObserver)null); - while (true) + for (int j = 0; j < this.textureList.size() && j < this.colorList.size(); ++j) + { + String s = (String)this.textureList.get(j); +// MapColor mapcolor = ((EnumDyeColor)this.field_174950_i.get(j)).getMapColor(); + int color; + if(this.colorList.get(j) instanceof EnumDyeColor){ + color = ((EnumDyeColor)this.colorList.get(j)).getMapColor().colorValue; + } + else{ + color = (Integer) this.colorList.get(j); + } + if (s != null) { - if (j >= 17 || j >= this.textureList.size() || j >= this.colorList.size()) - { - break label6; - } + InputStream inputstream = resourceManager.getResource(new ResourceLocation(s)).getInputStream(); + BufferedImage bufferedimage2 = TextureUtil.readBufferedImage(inputstream); - IResource iresource1 = null; - - try + if (bufferedimage2.getWidth() == bufferedimage.getWidth() && bufferedimage2.getHeight() == bufferedimage.getHeight() && bufferedimage2.getType() == 6) { - String s = (String)this.textureList.get(j); - //MapColor mapcolor = ((EnumDyeColor)this.c.get(j)).getMapColor(); - int color = (Integer) this.colorList.get(j); - if (s != null) + for (int k = 0; k < bufferedimage2.getHeight(); ++k) { - iresource1 = resourceManager.getResource(new ResourceLocation(s)); - BufferedImage bufferedimage2 = TextureUtil.readBufferedImage(iresource1.getInputStream()); - - if (bufferedimage2.getWidth() == bufferedimage.getWidth() && bufferedimage2.getHeight() == bufferedimage.getHeight() && bufferedimage2.getType() == 6) + for (int l = 0; l < bufferedimage2.getWidth(); ++l) { - for (int k = 0; k < bufferedimage2.getHeight(); ++k) - { - for (int l = 0; l < bufferedimage2.getWidth(); ++l) - { - int i1 = bufferedimage2.getRGB(l, k); + int i1 = bufferedimage2.getRGB(l, k); - if ((i1 & -16777216) != 0) - { - int j1 = (i1 & 16711680) << 8 & -16777216; - int k1 = bufferedimage1.getRGB(l, k); - int l1 = MathHelper.multiplyColor(k1, color) & 16777215; - bufferedimage2.setRGB(l, k, j1 | l1); - } - } + if ((i1 & -16777216) != 0) + { + int j1 = (i1 & 16711680) << 8 & -16777216; + int k1 = bufferedimage1.getRGB(l, k); + int l1 = MathHelper.func_180188_d(k1, color) & 16777215; + bufferedimage2.setRGB(l, k, j1 | l1); } - - bufferedimage.getGraphics().drawImage(bufferedimage2, 0, 0, (ImageObserver)null); } } - } - finally - { - IOUtils.closeQuietly((Closeable)iresource1); - } - ++j; + bufferedimage.getGraphics().drawImage(bufferedimage2, 0, 0, (ImageObserver)null); + } } } - catch (IOException ioexception) - { - LOG.error((String)"Couldn\'t load layered image", (Throwable)ioexception); - } - finally - { - IOUtils.closeQuietly((Closeable)iresource); - } - + } + catch (IOException ioexception) + { + LOG.error("Couldn\'t load layered image", ioexception); return; } + TextureUtil.uploadTextureImage(this.getGlTextureId(), bufferedimage); - } diff --git a/src/main/java/io/github/cvronmin/railwayp/client/renderer/texture/UnifedBannerTextures.java b/src/main/java/io/github/cvronmin/railwayp/client/renderer/texture/UnifedBannerTextures.java index b34af59..c4b73ba 100644 --- a/src/main/java/io/github/cvronmin/railwayp/client/renderer/texture/UnifedBannerTextures.java +++ b/src/main/java/io/github/cvronmin/railwayp/client/renderer/texture/UnifedBannerTextures.java @@ -7,13 +7,8 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import io.github.cvronmin.railwayp.RailwayP; import io.github.cvronmin.railwayp.tileentity.EnumUnifiedBannerPattern; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BannerTextures; -import net.minecraft.client.renderer.texture.LayeredColorMaskTexture; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.tileentity.TileEntityBanner; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; diff --git a/src/main/java/io/github/cvronmin/railwayp/init/RPBlocks.java b/src/main/java/io/github/cvronmin/railwayp/init/RPBlocks.java index 0e512df..f7bbdc7 100644 --- a/src/main/java/io/github/cvronmin/railwayp/init/RPBlocks.java +++ b/src/main/java/io/github/cvronmin/railwayp/init/RPBlocks.java @@ -33,10 +33,10 @@ public class RPBlocks { public static final BlockWHPF roof_where_pf = (BlockWHPF) new BlockWHPF.BlockBannerStanding().setUnlocalizedName("whpf"); public static final BlockWHPF wall_where_pf = (BlockWHPF) new BlockWHPF.BlockBannerHanging().setUnlocalizedName("whpf"); //焗漆板 - public static final BlockColorful plate = (BlockColorful) new BlockColorful(Material.IRON).setUnlocalizedName("plate"); + public static final BlockColorful plate = (BlockColorful) new BlockColorful(Material.iron).setUnlocalizedName("plate"); //紙皮石 - public static final BlockColorful mosaic_tile = (BlockColorful) new BlockColorful(Material.ROCK).setUnlocalizedName("mosaic_tile"); - public static final BlockRailNoticer noticer = (BlockRailNoticer) new BlockRailNoticer().setUnlocalizedName("noticer").setCreativeTab(CreativeTabs.TRANSPORTATION); + public static final BlockColorful mosaic_tile = (BlockColorful) new BlockColorful(Material.rock).setUnlocalizedName("mosaic_tile"); + public static final BlockRailNoticer noticer = (BlockRailNoticer) new BlockRailNoticer().setUnlocalizedName("noticer").setCreativeTab(CreativeTabs.tabTransport); public static void register(){ registerItemlessBlock(wall_platform_banner, "wall_platform_banner"); registerItemlessBlock(wall_name_banner, "wall_name_banner"); @@ -53,14 +53,13 @@ public static void register(){ } private static void registerItemlessBlock(Block block, String name){ ResourceLocation rl = new ResourceLocation(Reference.MODID, name); - GameRegistry.register(block.setRegistryName(rl)); + GameRegistry.registerBlock(block.setRegistryName(rl), (Class)null); } private static void registerBlock(Block block, String name){ registerBlock(block, new ItemBlock(block), name); } private static void registerBlock(Block block, ItemBlock itemBlock, String name){ ResourceLocation rl = new ResourceLocation(Reference.MODID, name); - GameRegistry.register(block.setRegistryName(rl)); - GameRegistry.register(itemBlock.setRegistryName(rl)); + GameRegistry.registerBlock(block.setRegistryName(rl)); } } diff --git a/src/main/java/io/github/cvronmin/railwayp/init/RPCraftingManager.java b/src/main/java/io/github/cvronmin/railwayp/init/RPCraftingManager.java index 02acee5..1531f66 100644 --- a/src/main/java/io/github/cvronmin/railwayp/init/RPCraftingManager.java +++ b/src/main/java/io/github/cvronmin/railwayp/init/RPCraftingManager.java @@ -1,171 +1,171 @@ -package io.github.cvronmin.railwayp.init; - -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.world.World; -import net.minecraftforge.fml.common.registry.GameRegistry; -import net.minecraftforge.oredict.RecipeSorter.Category; - -public class RPCraftingManager { - public static void register() { - GameRegistry.addRecipe(new ItemStack(RPItems.platform_banner, 2), new Object[]{ - "AAA", - "BBB", - 'A', new ItemStack(Blocks.STAINED_HARDENED_CLAY,1,EnumDyeColor.WHITE.getMetadata()), - 'B',Blocks.PLANKS}); - GameRegistry.addRecipe(new ItemStack(RPItems.whpf, 2), new Object[]{ - "AAA", - "BBB", - 'A', new ItemStack(Blocks.STAINED_HARDENED_CLAY,1,EnumDyeColor.BLACK.getMetadata()), - 'B',Blocks.PLANKS}); - GameRegistry.addRecipe(new ItemStack(RPItems.name_banner, 4), new Object[]{ - " A ", - "BBB", - 'A', Items.SIGN, - 'B',Blocks.STAINED_HARDENED_CLAY}); - GameRegistry.addRecipe(new ItemStack(RPItems.EDITOR, 1), new Object[]{ - " A", - " A ", - "B ", - 'A', Items.STICK, - 'B',Items.DYE}); - registerMosaticTile(); - registerPlate(); - net.minecraftforge.oredict.RecipeSorter.register("railwayp:cloning", CloningRecipe.class, Category.SHAPELESS, "after:minecraft:shapeless"); - registerCloningRecipe(); - } - private static void registerMosaticTile(){ - for(int i = 0;i < 16;i++){ - GameRegistry.addRecipe(new ItemStack(RPBlocks.mosaic_tile, 8, i), new Object[]{ - "ABA", - "BBB", - "ABA", - 'A', new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, i), - 'B',Items.QUARTZ}); - } - } - private static void registerPlate(){ - for(int i = 0;i < 16;i++){ - GameRegistry.addRecipe(new ItemStack(RPBlocks.plate, 8, i), new Object[]{ - "AAA", - "ABA", - "AAA", - 'B', new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, i), - 'A',Items.IRON_INGOT}); - } - } - private static void registerCloningRecipe(){ - GameRegistry.addRecipe(new CloningRecipe(RPItems.name_banner)); - GameRegistry.addRecipe(new CloningRecipe(RPItems.platform_banner)); - GameRegistry.addRecipe(new CloningRecipe(RPItems.whpf)); - GameRegistry.addRecipe(new CloningRecipe(RPItems.route_sign)); - GameRegistry.addRecipe(new CloningRecipe(Item.getItemFromBlock(RPBlocks.mosaic_tile))); - GameRegistry.addRecipe(new CloningRecipe(Item.getItemFromBlock(RPBlocks.plate))); - } - private static class CloningRecipe implements IRecipe{ - Item item; - public CloningRecipe(Item item) { - this.item = item; - } - @Override - public boolean matches(InventoryCrafting inv, World worldIn) { - int i = 0; - ItemStack itemstack = null; - - for (int j = 0; j < inv.getSizeInventory(); ++j) - { - ItemStack itemstack1 = inv.getStackInSlot(j); - - if (itemstack1 != null) - { - if(itemstack1.getItem() == item){ - if (itemstack1.hasTagCompound()) - { - if (itemstack != null) - { - return false; - } - - itemstack = itemstack1; - } - else ++i; - }else return false; - } - } - - return itemstack != null && i > 0; - } - - @Override - public ItemStack[] getRemainingItems(InventoryCrafting inv) { - ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()]; - - for (int i = 0; i < aitemstack.length; ++i) - { - ItemStack itemstack = inv.getStackInSlot(i); - aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack); - } - - return aitemstack; - } - - @Override - public int getRecipeSize() { - return 9; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting inv) { - int i = 0; - ItemStack itemstack = null; - - for (int j = 0; j < inv.getSizeInventory(); ++j) - { - ItemStack itemstack1 = inv.getStackInSlot(j); - - if (itemstack1 != null) - { - if(itemstack1.getItem() == item){ - if (itemstack1.hasTagCompound()) - { - if (itemstack != null) - { - return null; - } - - itemstack = itemstack1; - } - else ++i; - }else return null; - } - } - - if (itemstack != null && i >= 1) - { - ItemStack itemstack2 = new ItemStack(item, i + 1, itemstack.getMetadata()); - - if (itemstack.hasDisplayName()) - { - itemstack2.setStackDisplayName(itemstack.getDisplayName()); - } - itemstack2.setTagCompound(itemstack.getTagCompound()); - - return itemstack2; - } - else - { - return null; - } - } - } -} +package io.github.cvronmin.railwayp.init; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.World; +import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.oredict.RecipeSorter.Category; + +public class RPCraftingManager { + public static void register() { + GameRegistry.addRecipe(new ItemStack(RPItems.platform_banner, 2), new Object[]{ + "AAA", + "BBB", + 'A', new ItemStack(Blocks.stained_hardened_clay,1,EnumDyeColor.WHITE.getMetadata()), + 'B',Blocks.planks}); + GameRegistry.addRecipe(new ItemStack(RPItems.whpf, 2), new Object[]{ + "AAA", + "BBB", + 'A', new ItemStack(Blocks.stained_hardened_clay,1,EnumDyeColor.BLACK.getMetadata()), + 'B',Blocks.planks}); + GameRegistry.addRecipe(new ItemStack(RPItems.name_banner, 4), new Object[]{ + " A ", + "BBB", + 'A', Items.sign, + 'B',Blocks.stained_hardened_clay}); + GameRegistry.addRecipe(new ItemStack(RPItems.EDITOR, 1), new Object[]{ + " A", + " A ", + "B ", + 'A', Items.stick, + 'B',Items.dye}); + registerMosaticTile(); + registerPlate(); + net.minecraftforge.oredict.RecipeSorter.register("railwayp:cloning", CloningRecipe.class, Category.SHAPELESS, "after:minecraft:shapeless"); + registerCloningRecipe(); + } + private static void registerMosaticTile(){ + for(int i = 0;i < 16;i++){ + GameRegistry.addRecipe(new ItemStack(RPBlocks.mosaic_tile, 8, i), new Object[]{ + "ABA", + "BBB", + "ABA", + 'A', new ItemStack(Blocks.stained_hardened_clay, 1, i), + 'B',Items.quartz}); + } + } + private static void registerPlate(){ + for(int i = 0;i < 16;i++){ + GameRegistry.addRecipe(new ItemStack(RPBlocks.plate, 8, i), new Object[]{ + "AAA", + "ABA", + "AAA", + 'B', new ItemStack(Blocks.stained_hardened_clay, 1, i), + 'A',Items.iron_ingot}); + } + } + private static void registerCloningRecipe(){ + GameRegistry.addRecipe(new CloningRecipe(RPItems.name_banner)); + GameRegistry.addRecipe(new CloningRecipe(RPItems.platform_banner)); + GameRegistry.addRecipe(new CloningRecipe(RPItems.whpf)); + GameRegistry.addRecipe(new CloningRecipe(RPItems.route_sign)); + GameRegistry.addRecipe(new CloningRecipe(Item.getItemFromBlock(RPBlocks.mosaic_tile))); + GameRegistry.addRecipe(new CloningRecipe(Item.getItemFromBlock(RPBlocks.plate))); + } + private static class CloningRecipe implements IRecipe{ + Item item; + public CloningRecipe(Item item) { + this.item = item; + } + @Override + public boolean matches(InventoryCrafting inv, World worldIn) { + int i = 0; + ItemStack itemstack = null; + + for (int j = 0; j < inv.getSizeInventory(); ++j) + { + ItemStack itemstack1 = inv.getStackInSlot(j); + + if (itemstack1 != null) + { + if(itemstack1.getItem() == item){ + if (itemstack1.hasTagCompound()) + { + if (itemstack != null) + { + return false; + } + + itemstack = itemstack1; + } + else ++i; + }else return false; + } + } + + return itemstack != null && i > 0; + } + + @Override + public ItemStack[] getRemainingItems(InventoryCrafting inv) { + ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()]; + + for (int i = 0; i < aitemstack.length; ++i) + { + ItemStack itemstack = inv.getStackInSlot(i); + aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack); + } + + return aitemstack; + } + + @Override + public int getRecipeSize() { + return 9; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting inv) { + int i = 0; + ItemStack itemstack = null; + + for (int j = 0; j < inv.getSizeInventory(); ++j) + { + ItemStack itemstack1 = inv.getStackInSlot(j); + + if (itemstack1 != null) + { + if(itemstack1.getItem() == item){ + if (itemstack1.hasTagCompound()) + { + if (itemstack != null) + { + return null; + } + + itemstack = itemstack1; + } + else ++i; + }else return null; + } + } + + if (itemstack != null && i >= 1) + { + ItemStack itemstack2 = new ItemStack(item, i + 1, itemstack.getMetadata()); + + if (itemstack.hasDisplayName()) + { + itemstack2.setStackDisplayName(itemstack.getDisplayName()); + } + itemstack2.setTagCompound(itemstack.getTagCompound()); + + return itemstack2; + } + else + { + return null; + } + } + } +} diff --git a/src/main/java/io/github/cvronmin/railwayp/init/RPItems.java b/src/main/java/io/github/cvronmin/railwayp/init/RPItems.java index 7dc3950..3164bbc 100644 --- a/src/main/java/io/github/cvronmin/railwayp/init/RPItems.java +++ b/src/main/java/io/github/cvronmin/railwayp/init/RPItems.java @@ -24,6 +24,6 @@ public static void register(){ registerItem(EDITOR, "editor"); } private static void registerItem(Item item, String name){ - GameRegistry.register(item.setRegistryName(new ResourceLocation(Reference.MODID, name))); + GameRegistry.registerItem(item.setRegistryName(new ResourceLocation(Reference.MODID, name))); } } diff --git a/src/main/java/io/github/cvronmin/railwayp/item/ItemEditor.java b/src/main/java/io/github/cvronmin/railwayp/item/ItemEditor.java index 5514a5e..623ae9e 100644 --- a/src/main/java/io/github/cvronmin/railwayp/item/ItemEditor.java +++ b/src/main/java/io/github/cvronmin/railwayp/item/ItemEditor.java @@ -10,10 +10,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumActionResult; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.relauncher.Side; @@ -27,24 +25,25 @@ public ItemEditor(){ * Called when a Block is right-clicked with this Item */ @SideOnly(Side.CLIENT) - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ) { if(!worldIn.isRemote){ - return EnumActionResult.PASS; + return true; } TileEntity te = worldIn.getTileEntity(pos); if (te instanceof TileEntityPlatformBanner) { FMLClientHandler.instance().getClient().displayGuiScreen(new GuiPlatformBannerEditor((TileEntityPlatformBanner) te)); - return EnumActionResult.SUCCESS; + return true; } if (te instanceof TileEntityNameBanner) { FMLClientHandler.instance().getClient().displayGuiScreen(new GuiNameBannerEditor((TileEntityNameBanner) te)); - return EnumActionResult.SUCCESS; + return true; } if (te instanceof TileEntityWHPF) { FMLClientHandler.instance().getClient().displayGuiScreen(new GuiWHPFEditor((TileEntityWHPF) te)); - return EnumActionResult.SUCCESS; + return true; } - return EnumActionResult.PASS; + return true; } } diff --git a/src/main/java/io/github/cvronmin/railwayp/item/ItemNameBanner.java b/src/main/java/io/github/cvronmin/railwayp/item/ItemNameBanner.java index 5461139..571bde6 100644 --- a/src/main/java/io/github/cvronmin/railwayp/item/ItemNameBanner.java +++ b/src/main/java/io/github/cvronmin/railwayp/item/ItemNameBanner.java @@ -10,10 +10,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumActionResult; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -25,7 +23,7 @@ public ItemNameBanner() { super(); this.maxStackSize = 16; - this.setCreativeTab(CreativeTabs.DECORATIONS); + this.setCreativeTab(CreativeTabs.tabDecorations); } public ItemNameBanner(Block block){ this(); @@ -37,16 +35,16 @@ public ItemNameBanner(Block block){ * @param pos The block being right-clicked * @param side The side being right-clicked */ - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) + public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ) { IBlockState state = worldIn.getBlockState(pos); if (facing == EnumFacing.DOWN || facing == EnumFacing.UP) { - return EnumActionResult.FAIL; + return false; } - else if (!state.getBlock().getMaterial(state).isSolid()) + else if (!state.getBlock().getMaterial().isSolid()) { - return EnumActionResult.FAIL; + return false; } else { @@ -54,11 +52,11 @@ else if (!state.getBlock().getMaterial(state).isSolid()) if (!playerIn.canPlayerEdit(pos, facing, stack)) { - return EnumActionResult.FAIL; + return false; } else if (worldIn.isRemote) { - return EnumActionResult.PASS; + return true; } else { @@ -71,17 +69,9 @@ else if (worldIn.isRemote) ((TileEntityNameBanner)tileentity).setItemValues(stack); } - return EnumActionResult.SUCCESS; + return true; } } } - /** - * gets the CreativeTab this item is displayed on - */ - @SideOnly(Side.CLIENT) - public CreativeTabs getCreativeTab() - { - return CreativeTabs.DECORATIONS; - } } \ No newline at end of file diff --git a/src/main/java/io/github/cvronmin/railwayp/item/ItemPlatformBanner.java b/src/main/java/io/github/cvronmin/railwayp/item/ItemPlatformBanner.java index e98a6e9..8df2dc0 100644 --- a/src/main/java/io/github/cvronmin/railwayp/item/ItemPlatformBanner.java +++ b/src/main/java/io/github/cvronmin/railwayp/item/ItemPlatformBanner.java @@ -10,10 +10,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumActionResult; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -25,7 +23,7 @@ public ItemPlatformBanner() { super(); this.maxStackSize = 16; - this.setCreativeTab(CreativeTabs.DECORATIONS); + this.setCreativeTab(CreativeTabs.tabDecorations); } public ItemPlatformBanner(Block block){ this(); @@ -37,16 +35,16 @@ public ItemPlatformBanner(Block block){ * @param pos The block being right-clicked * @param side The side being right-clicked */ - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) + public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ) { IBlockState state = worldIn.getBlockState(pos); if (facing == EnumFacing.DOWN || facing == EnumFacing.UP) { - return EnumActionResult.FAIL; + return false; } - else if (!state.getBlock().getMaterial(state).isSolid()) + else if (!state.getBlock().getMaterial().isSolid()) { - return EnumActionResult.FAIL; + return false; } else { @@ -54,11 +52,11 @@ else if (!state.getBlock().getMaterial(state).isSolid()) if (!playerIn.canPlayerEdit(pos, facing, stack)) { - return EnumActionResult.FAIL; + return false; } else if (worldIn.isRemote) { - return EnumActionResult.PASS; + return true; } else { @@ -71,7 +69,7 @@ else if (worldIn.isRemote) ((TileEntityPlatformBanner)tileentity).setItemValues(stack); } - return EnumActionResult.SUCCESS; + return true; } } } @@ -106,7 +104,7 @@ public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) @SideOnly(Side.CLIENT) public CreativeTabs getCreativeTab() { - return CreativeTabs.DECORATIONS; + return CreativeTabs.tabDecorations; } } \ No newline at end of file diff --git a/src/main/java/io/github/cvronmin/railwayp/item/ItemRouteSignage.java b/src/main/java/io/github/cvronmin/railwayp/item/ItemRouteSignage.java index feea598..154d2d6 100644 --- a/src/main/java/io/github/cvronmin/railwayp/item/ItemRouteSignage.java +++ b/src/main/java/io/github/cvronmin/railwayp/item/ItemRouteSignage.java @@ -10,10 +10,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumActionResult; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -24,7 +22,7 @@ public ItemRouteSignage() { super(); this.maxStackSize = 16; - this.setCreativeTab(CreativeTabs.DECORATIONS); + this.setCreativeTab(CreativeTabs.tabDecorations); } public ItemRouteSignage(Block block){ this(); @@ -36,16 +34,16 @@ public ItemRouteSignage(Block block){ * @param pos The block being right-clicked * @param side The side being right-clicked */ - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) + public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ) { IBlockState state = worldIn.getBlockState(pos); if (facing == EnumFacing.DOWN || facing == EnumFacing.UP) { - return EnumActionResult.FAIL; + return false; } - else if (!state.getBlock().getMaterial(state).isSolid()) + else if (!state.getBlock().getMaterial().isSolid()) { - return EnumActionResult.FAIL; + return false; } else { @@ -53,11 +51,11 @@ else if (!state.getBlock().getMaterial(state).isSolid()) if (!playerIn.canPlayerEdit(pos, facing, stack)) { - return EnumActionResult.FAIL; + return false; } else if (worldIn.isRemote) { - return EnumActionResult.PASS; + return true; } else { @@ -70,7 +68,7 @@ else if (worldIn.isRemote) ((TileEntityRouteSignage)tileentity).setItemValues(stack); } - return EnumActionResult.SUCCESS; + return true; } } } @@ -105,7 +103,7 @@ public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) @SideOnly(Side.CLIENT) public CreativeTabs getCreativeTab() { - return CreativeTabs.DECORATIONS; + return CreativeTabs.tabDecorations; } } diff --git a/src/main/java/io/github/cvronmin/railwayp/item/ItemWHPF.java b/src/main/java/io/github/cvronmin/railwayp/item/ItemWHPF.java index 294fcbb..12d4c7a 100644 --- a/src/main/java/io/github/cvronmin/railwayp/item/ItemWHPF.java +++ b/src/main/java/io/github/cvronmin/railwayp/item/ItemWHPF.java @@ -4,19 +4,14 @@ import io.github.cvronmin.railwayp.init.RPBlocks; import io.github.cvronmin.railwayp.tileentity.TileEntityWHPF; import net.minecraft.block.Block; -import net.minecraft.block.BlockStandingSign; -import net.minecraft.block.BlockWallSign; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumActionResult; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -28,7 +23,7 @@ public ItemWHPF() { super(); this.maxStackSize = 16; - this.setCreativeTab(CreativeTabs.DECORATIONS); + this.setCreativeTab(CreativeTabs.tabDecorations); } public ItemWHPF(Block block){ this(); @@ -40,16 +35,16 @@ public ItemWHPF(Block block){ * @param pos The block being right-clicked * @param side The side being right-clicked */ - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) + public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ) { IBlockState state = worldIn.getBlockState(pos); if (facing == EnumFacing.UP) { - return EnumActionResult.FAIL; + return false; } - else if (!state.getBlock().getMaterial(state).isSolid()) + else if (!state.getBlock().getMaterial().isSolid()) { - return EnumActionResult.FAIL; + return false; } else { @@ -57,15 +52,15 @@ else if (!state.getBlock().getMaterial(state).isSolid()) if (!playerIn.canPlayerEdit(pos, facing, stack)) { - return EnumActionResult.FAIL; + return false; } else if (worldIn.isRemote) { - return EnumActionResult.PASS; + return true; } else if (!RPBlocks.roof_where_pf.canPlaceBlockAt(worldIn, pos)) { - return EnumActionResult.FAIL; + return false; } else { @@ -98,7 +93,7 @@ else if (!RPBlocks.roof_where_pf.canPlaceBlockAt(worldIn, pos)) ((TileEntityWHPF)tileentity).setRotation((short) (playerIn.rotationYaw + 180)); } - return EnumActionResult.SUCCESS; + return true; } } } @@ -133,7 +128,7 @@ public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) @SideOnly(Side.CLIENT) public CreativeTabs getCreativeTab() { - return CreativeTabs.DECORATIONS; + return CreativeTabs.tabDecorations; } } \ No newline at end of file diff --git a/src/main/java/io/github/cvronmin/railwayp/network/CUpdateBannerByGui.java b/src/main/java/io/github/cvronmin/railwayp/network/CUpdateBannerByGui.java index e59c9de..88f6e12 100644 --- a/src/main/java/io/github/cvronmin/railwayp/network/CUpdateBannerByGui.java +++ b/src/main/java/io/github/cvronmin/railwayp/network/CUpdateBannerByGui.java @@ -1,8 +1,6 @@ package io.github.cvronmin.railwayp.network; -import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -10,7 +8,7 @@ import io.github.cvronmin.railwayp.Reference; import io.netty.buffer.ByteBuf; -import net.minecraft.util.math.BlockPos; +import net.minecraft.util.BlockPos; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; diff --git a/src/main/java/io/github/cvronmin/railwayp/network/MessagerFromClient.java b/src/main/java/io/github/cvronmin/railwayp/network/MessagerFromClient.java index f7ea6b8..6099ba8 100644 --- a/src/main/java/io/github/cvronmin/railwayp/network/MessagerFromClient.java +++ b/src/main/java/io/github/cvronmin/railwayp/network/MessagerFromClient.java @@ -9,7 +9,7 @@ import io.github.cvronmin.railwayp.tileentity.TileEntityPlatformBanner; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.util.BlockPos; import net.minecraft.world.WorldServer; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; @@ -42,7 +42,7 @@ public IMessage onMessage(final CUpdateBannerByGui message, MessageContext ctx) // for example see MinecraftServer.updateTimeLightAndEntities(), just under section // this.theProfiler.startSection("jobs"); // In this case, the task is to call messageHandlerOnServer.processMessage(message, sendingPlayer) - final WorldServer playerWorldServer = sendingPlayer.getServerWorld(); + final WorldServer playerWorldServer = sendingPlayer.getServerForPlayer(); playerWorldServer.addScheduledTask(new Runnable() { public void run() { processMessage(message, sendingPlayer); diff --git a/src/main/java/io/github/cvronmin/railwayp/network/MessagerFromServer.java b/src/main/java/io/github/cvronmin/railwayp/network/MessagerFromServer.java index 620d06e..9f0fd60 100644 --- a/src/main/java/io/github/cvronmin/railwayp/network/MessagerFromServer.java +++ b/src/main/java/io/github/cvronmin/railwayp/network/MessagerFromServer.java @@ -1,20 +1,10 @@ package io.github.cvronmin.railwayp.network; -import java.util.Map; -import java.util.Map.Entry; - -import org.apache.logging.log4j.Level; - -import io.github.cvronmin.railwayp.Reference; import io.github.cvronmin.railwayp.client.ClientProxy; -import io.github.cvronmin.railwayp.tileentity.TileEntityPlatformBanner; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; -import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; @@ -46,7 +36,7 @@ public IMessage onMessage(final SUpdateRailNoticerGui message, MessageContext ct // for example see MinecraftServer.updateTimeLightAndEntities(), just under section // this.theProfiler.startSection("jobs"); // In this case, the task is to call messageHandlerOnServer.processMessage(message, sendingPlayer) - final WorldServer playerWorldServer = sendingPlayer.getServerWorld(); + final WorldServer playerWorldServer = sendingPlayer.getServerForPlayer(); playerWorldServer.addScheduledTask(new Runnable() { public void run() { processMessage(worldClient, message); diff --git a/src/main/java/io/github/cvronmin/railwayp/network/RPPacket.java b/src/main/java/io/github/cvronmin/railwayp/network/RPPacket.java index f3ae50c..4b22eef 100644 --- a/src/main/java/io/github/cvronmin/railwayp/network/RPPacket.java +++ b/src/main/java/io/github/cvronmin/railwayp/network/RPPacket.java @@ -1,6 +1,5 @@ package io.github.cvronmin.railwayp.network; -import java.io.IOException; import java.util.Arrays; import java.util.List; @@ -8,7 +7,6 @@ import com.jcraft.jogg.Packet; -import io.github.cvronmin.railwayp.RailwayP; import io.github.cvronmin.railwayp.Reference; import io.github.cvronmin.railwayp.client.ClientProxy; import io.github.cvronmin.railwayp.tileentity.TileEntityNameBanner; @@ -19,16 +17,13 @@ import io.netty.channel.ChannelHandlerContext; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.network.NetHandlerPlayServer; import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.util.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.relauncher.Side; -import scala.annotation.bridge; public class RPPacket extends Packet implements IRPPacket { @@ -163,7 +158,7 @@ public void handleClientSide(EntityPlayer player) { if(dir.isEmpty())dir = "0"; te.setData(Integer.valueOf(pf), Byte.valueOf(dir), String.valueOf(data.get(5)), String.valueOf(data.get(6)), String.valueOf(data.get(7))); te.markDirty(); - world.notifyBlockUpdate(blockpos1, state, state, 3); + world.markBlockForUpdate(blockpos1); } catch (Exception e) { FMLLog.log(Reference.MODID, Level.ERROR, e, ""); } @@ -182,7 +177,7 @@ public void handleClientSide(EntityPlayer player) { if(signtype.isEmpty())signtype = "0"; te1.setData(Integer.valueOf(signtype), String.valueOf(data.get(4)), String.valueOf(data.get(5)), String.valueOf(data.get(6)), String.valueOf(data.get(7))); te1.markDirty(); - world1.notifyBlockUpdate(blockpos11, state1, state1, 3); + world1.markBlockForUpdate(blockpos11); } catch (Exception e) { FMLLog.log(Reference.MODID, Level.ERROR, e, ""); } @@ -205,7 +200,7 @@ public void handleClientSide(EntityPlayer player) { if(r.isEmpty())r = "0"; te11.setData(Integer.valueOf(pf1), Byte.parseByte(dir), Short.parseShort(r), String.valueOf(data.get(6)), String.valueOf(data.get(7)), String.valueOf(data.get(8))); te11.markDirty(); - world11.notifyBlockUpdate(blockpos111, state11, state11, 3); + world11.markBlockForUpdate(blockpos111); } catch (Exception e) { FMLLog.log(Reference.MODID, Level.ERROR, e, ""); } @@ -247,7 +242,7 @@ public void handleServerSide(EntityPlayer player) { if(dir.isEmpty())dir = "0"; te.setData(Integer.valueOf(pf), Byte.valueOf(dir), String.valueOf(data.get(5)), String.valueOf(data.get(6)), String.valueOf(data.get(7))); te.markDirty(); - world.notifyBlockUpdate(blockpos1, state, state, 3); + world.markBlockForUpdate(blockpos1); } catch (Exception e) { FMLLog.log(Reference.MODID, Level.ERROR, e, ""); } @@ -266,7 +261,7 @@ public void handleServerSide(EntityPlayer player) { if(signtype.isEmpty())signtype = "0"; te1.setData(Integer.valueOf(signtype), String.valueOf(data.get(4)), String.valueOf(data.get(5)), String.valueOf(data.get(6)), String.valueOf(data.get(7))); te1.markDirty(); - world1.notifyBlockUpdate(blockpos11, state1, state1, 3); + world1.markBlockForUpdate(blockpos11); } catch (Exception e) { FMLLog.log(Reference.MODID, Level.ERROR, e, ""); } @@ -289,7 +284,7 @@ public void handleServerSide(EntityPlayer player) { if(r.isEmpty())r = "0"; te11.setData(Integer.valueOf(pf1), Byte.parseByte(dir), Short.parseShort(r), String.valueOf(data.get(6)), String.valueOf(data.get(7)), String.valueOf(data.get(8))); te11.markDirty(); - world11.notifyBlockUpdate(blockpos111, state11, state11, 3); + world11.markBlockForUpdate(blockpos111); } catch (Exception e) { FMLLog.log(Reference.MODID, Level.ERROR, e, ""); } diff --git a/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityColorful.java b/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityColorful.java index c545ebc..1118d1f 100644 --- a/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityColorful.java +++ b/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityColorful.java @@ -2,8 +2,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.Packet; -import net.minecraft.network.play.server.SPacketUpdateTileEntity; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntityBanner; public class TileEntityColorful extends TileEntityBanner { @@ -71,6 +70,6 @@ public short getRotation() { public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); - return new SPacketUpdateTileEntity(this.pos, 6, nbttagcompound); + return new S35PacketUpdateTileEntity(this.pos, 6, nbttagcompound); } } diff --git a/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityNameBanner.java b/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityNameBanner.java index 4b1ca2d..ca0cfcf 100644 --- a/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityNameBanner.java +++ b/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityNameBanner.java @@ -4,22 +4,19 @@ import com.google.common.collect.Lists; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumDyeColor; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.Packet; -import net.minecraft.network.play.server.SPacketUpdateTileEntity; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntityBanner; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class TileEntityNameBanner extends TileEntityBanner { - public final ITextComponent[] signText = new ITextComponent[] {new TextComponentString(""), new TextComponentString("")}; + public final IChatComponent[] signText = new IChatComponent[] {new ChatComponentText(""), new ChatComponentText("")}; private int color; private String colorEncoded; /** A list of all patterns stored on this banner. */ @@ -99,7 +96,7 @@ public void setItemValues(ItemStack stack) if(nbttagcompound.hasKey("Text" + (i + 1))){ String s = nbttagcompound.getString("Text" + (i + 1)); - ITextComponent ichatcomponent = ITextComponent.Serializer.jsonToComponent(s); + IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s); this.signText[i] = ichatcomponent; } } @@ -123,7 +120,7 @@ public void writeToNBT(NBTTagCompound compound) compound.setInteger("SignType", bannerType); for (int i = 0; i < 2; ++i) { - String s = ITextComponent.Serializer.componentToJson(this.signText[i]); + String s = IChatComponent.Serializer.componentToJson(this.signText[i]); compound.setString("Text" + (i + 1), s); } } @@ -139,7 +136,7 @@ public void readFromNBT(NBTTagCompound compound) for (int i = 0; i < 2; ++i) { String s = compound.getString("Text" + (i + 1)); - ITextComponent ichatcomponent = ITextComponent.Serializer.jsonToComponent(s); + IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s); this.signText[i] = ichatcomponent; } this.patternList = null; @@ -191,7 +188,7 @@ public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); - return new SPacketUpdateTileEntity(this.pos, 6, nbttagcompound); + return new S35PacketUpdateTileEntity(this.pos, 6, nbttagcompound); } /** * Establishes all of the basic properties for the banner. This will also apply the data from the tile entities nbt @@ -248,7 +245,7 @@ private void initializeBannerData() } } private boolean checkGoodBanner(){ - boolean flag = color > 0x0 && color < 0x1000000; + boolean flag = color >= 0x0 && color < 0x1000000; boolean flag1 = stationColor >= 0x0 && stationColor < 0x1000000; return flag && flag1; } @@ -256,8 +253,8 @@ public void setData(int st, String sc, String c, String t1, String t2) { bannerType = st; stationColorEncoded = sc; colorEncoded = c; - signText[0] = new TextComponentString(t1); - signText[1] = new TextComponentString(t2); + signText[0] = new ChatComponentText(t1); + signText[1] = new ChatComponentText(t2); decodeColor(); decodeStationColor(); } diff --git a/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityPFDoor.java b/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityPFDoor.java index 8b97522..8e1796b 100644 --- a/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityPFDoor.java +++ b/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityPFDoor.java @@ -7,18 +7,14 @@ import io.github.cvronmin.railwayp.init.RPBlocks; import net.minecraft.block.Block; -import net.minecraft.block.material.EnumPushReaction; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; -import net.minecraft.init.Blocks; //import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -82,89 +78,36 @@ public float getProgress(float p_145860_1_) return this.lastProgress + (this.progress - this.lastProgress) * p_145860_1_; } - private float func_184320_e(float p_184320_1_) - { - return this.extending ? p_184320_1_ - 1.0F : 1.0F - p_184320_1_; - } - private void func_184322_i() + + private void func_145863_a(float p_145863_1_, float p_145863_2_) { - AxisAlignedBB axisalignedbb = this.func_184321_a(this.worldObj, this.pos).offset(this.pos); - List list = this.worldObj.getEntitiesWithinAABBExcludingEntity((Entity)null, axisalignedbb); + if (this.extending) + { + p_145863_1_ = 1.0F - p_145863_1_; + } + else + { + --p_145863_1_; + } + + AxisAlignedBB axisalignedbb = RPBlocks.platform_door_extension.getBoundingBox(this.worldObj, this.pos, this.pistonState, p_145863_1_, this.pistonFacing); - if (!list.isEmpty()) + if (axisalignedbb != null) { - EnumFacing enumfacing = this.extending ? this.pistonFacing : this.pistonFacing.getOpposite(); + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity((Entity)null, axisalignedbb); - for (int i = 0; i < list.size(); ++i) + if (!list.isEmpty()) { - Entity entity = (Entity)list.get(i); + this.field_174933_k.addAll(list); + Iterator iterator = this.field_174933_k.iterator(); - if (entity.getPushReaction() != EnumPushReaction.IGNORE) + while (iterator.hasNext()) { - if (this.pistonState.getBlock() == Blocks.SLIME_BLOCK) - { - switch (enumfacing.getAxis()) - { - case X: - entity.motionX = (double)enumfacing.getFrontOffsetX(); - break; - case Y: - entity.motionY = (double)enumfacing.getFrontOffsetY(); - break; - case Z: - entity.motionZ = (double)enumfacing.getFrontOffsetZ(); - } - } - - double d0 = 0.0D; - double d1 = 0.0D; - double d2 = 0.0D; - AxisAlignedBB axisalignedbb1 = entity.getEntityBoundingBox(); - - switch (enumfacing.getAxis()) - { - case X: - - if (enumfacing.getAxisDirection() == EnumFacing.AxisDirection.POSITIVE) - { - d0 = axisalignedbb.maxX - axisalignedbb1.minX; - } - else - { - d0 = axisalignedbb1.maxX - axisalignedbb.minX; - } - - d0 = d0 + 0.01D; - break; - case Y: - - if (enumfacing.getAxisDirection() == EnumFacing.AxisDirection.POSITIVE) - { - d1 = axisalignedbb.maxY - axisalignedbb1.minY; - } - else - { - d1 = axisalignedbb1.maxY - axisalignedbb.minY; - } - - d1 = d1 + 0.01D; - break; - case Z: - - if (enumfacing.getAxisDirection() == EnumFacing.AxisDirection.POSITIVE) - { - d2 = axisalignedbb.maxZ - axisalignedbb1.minZ; - } - else - { - d2 = axisalignedbb1.maxZ - axisalignedbb.minZ; - } - - d2 = d2 + 0.01D; - } - - entity.moveEntity(d0 * (double)enumfacing.getFrontOffsetX(), d1 * (double)enumfacing.getFrontOffsetY(), d2 * (double)enumfacing.getFrontOffsetZ()); + Entity entity = (Entity)iterator.next(); + entity.moveEntity((double)(p_145863_2_ * (float)this.pistonFacing.getFrontOffsetX()), (double)(p_145863_2_ * (float)this.pistonFacing.getFrontOffsetY()), (double)(p_145863_2_ * (float)this.pistonFacing.getFrontOffsetZ())); } + + this.field_174933_k.clear(); } } } @@ -216,7 +159,7 @@ public void update() if (this.lastProgress >= 1.0F) { - this.func_184322_i(); + this.func_145863_a(1.0F, 0.25F); this.worldObj.removeTileEntity(this.pos); this.invalidate(); @@ -238,7 +181,7 @@ public void update() if (this.extending) { - this.func_184322_i(); + this.func_145863_a(this.progress, this.progress - this.lastProgress + 0.0625F); } } } @@ -261,16 +204,7 @@ public void writeToNBT(NBTTagCompound compound) compound.setFloat("progress", this.lastProgress); compound.setBoolean("extending", this.extending); } - public AxisAlignedBB func_184321_a(IBlockAccess p_184321_1_, BlockPos p_184321_2_) - { - return this.func_184319_a(p_184321_1_, p_184321_2_, this.progress).union(this.func_184319_a(p_184321_1_, p_184321_2_, this.lastProgress)); - } - public AxisAlignedBB func_184319_a(IBlockAccess p_184319_1_, BlockPos p_184319_2_, float p_184319_3_) - { - p_184319_3_ = this.func_184320_e(p_184319_3_); - return this.pistonState.getBoundingBox(p_184319_1_, p_184319_2_).offset((double)(p_184319_3_ * (float)this.pistonFacing.getFrontOffsetX()), (double)(p_184319_3_ * (float)this.pistonFacing.getFrontOffsetY()), (double)(p_184319_3_ * (float)this.pistonFacing.getFrontOffsetZ())); - } static final class SwitchAxis { static final int[] field_177248_a = new int[EnumFacing.Axis.values().length]; diff --git a/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityPlatformBanner.java b/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityPlatformBanner.java index 0e796b6..76432ea 100644 --- a/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityPlatformBanner.java +++ b/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityPlatformBanner.java @@ -3,25 +3,22 @@ import java.util.List; import com.google.common.collect.Lists; -import com.google.gson.JsonParseException; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.Packet; -import net.minecraft.network.play.server.SPacketUpdateTileEntity; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntityBanner; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class TileEntityPlatformBanner extends TileEntityBanner { - public final ITextComponent[] signText = new ITextComponent[] {new TextComponentString(""), new TextComponentString("")}; + public final IChatComponent[] signText = new IChatComponent[] {new ChatComponentText(""), new ChatComponentText("")}; public boolean shouldExtend; private boolean patternDataSet; /** A list of all patterns stored on this banner. */ @@ -84,7 +81,7 @@ public void setItemValues(ItemStack stack) String s = nbttagcompound.getString("Text" + (i + 1)); - ITextComponent ichatcomponent = ITextComponent.Serializer.jsonToComponent(s); + IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s); this.signText[i] = ichatcomponent; } @@ -113,7 +110,7 @@ public void writeToNBT(NBTTagCompound compound) compound.setBoolean("ShouldExtend", shouldExtend); for (int i = 0; i < 2; ++i) { - String s = ITextComponent.Serializer.componentToJson(this.signText[i]); + String s = IChatComponent.Serializer.componentToJson(this.signText[i]); compound.setString("Text" + (i + 1), s); } } @@ -142,7 +139,7 @@ public void readFromNBT(NBTTagCompound compound) { String s = compound.getString("Text" + (i + 1)); - ITextComponent ichatcomponent = ITextComponent.Serializer.jsonToComponent(s); + IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s); this.signText[i] = ichatcomponent; } this.patternList = null; @@ -159,7 +156,7 @@ public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); - return new SPacketUpdateTileEntity(this.pos, 6, nbttagcompound); + return new S35PacketUpdateTileEntity(this.pos, 6, nbttagcompound); } public static int getBaseColor(ItemStack stack) @@ -197,7 +194,7 @@ public List getColorList() return this.colorList; } - public ITextComponent[] getSignText() { + public IChatComponent[] getSignText() { return signText; } @@ -314,8 +311,8 @@ public void setData(int pn, byte dir, String color, String t1, String t2){ this.route = pn; this.direction = dir; this.routeColorEncoded = color; - this.signText[0] = new TextComponentString(t1); - this.signText[1] = new TextComponentString(t2); + this.signText[0] = new ChatComponentText(t1); + this.signText[1] = new ChatComponentText(t2); decodeColor(); } } \ No newline at end of file diff --git a/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityRailNoticer.java b/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityRailNoticer.java index 2563c88..54f7f94 100644 --- a/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityRailNoticer.java +++ b/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityRailNoticer.java @@ -5,7 +5,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.Packet; -import net.minecraft.network.play.server.SPacketUpdateTileEntity; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; public class TileEntityRailNoticer extends TileEntity { @@ -38,7 +38,7 @@ public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); - return new SPacketUpdateTileEntity(this.pos, 6, nbttagcompound); + return new S35PacketUpdateTileEntity(this.pos, 6, nbttagcompound); } public boolean sendNotice(EntityPlayerMP player){ sendNotice(player, thisStat, RPPacket.EnumRPPacket.C_UPDATETHISSTATION); diff --git a/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityRouteSignage.java b/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityRouteSignage.java index c55f7cc..ba76019 100644 --- a/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityRouteSignage.java +++ b/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityRouteSignage.java @@ -4,22 +4,21 @@ import com.google.common.collect.Lists; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.Packet; -import net.minecraft.network.play.server.SPacketUpdateTileEntity; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntityBanner; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class TileEntityRouteSignage extends TileEntityBanner{ - public final ITextComponent[] stationText = new ITextComponent[] {new TextComponentString(""), new TextComponentString("")}; - public final ITextComponent[] nextText = new ITextComponent[] {new TextComponentString(""), new TextComponentString("")}; + public final IChatComponent[] stationText = new IChatComponent[] {new ChatComponentText(""), new ChatComponentText("")}; + public final IChatComponent[] nextText = new IChatComponent[] {new ChatComponentText(""), new ChatComponentText("")}; // private NBTTagList stations; private int baseColor; private boolean field_175119_g; @@ -76,7 +75,7 @@ public void setItemValues(ItemStack stack) String s = nbttagcompound.getString("StationText" + (i + 1)); - ITextComponent ichatcomponent = ITextComponent.Serializer.jsonToComponent(s); + IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s); this.stationText[i] = ichatcomponent; } @@ -87,7 +86,7 @@ public void setItemValues(ItemStack stack) String s = nbttagcompound.getString("NextText" + (i + 1)); - ITextComponent ichatcomponent = ITextComponent.Serializer.jsonToComponent(s); + IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s); this.nextText[i] = ichatcomponent; } @@ -111,12 +110,12 @@ public void writeToNBT(NBTTagCompound compound) } for (int i = 0; i < 2; ++i) { - String s = ITextComponent.Serializer.componentToJson(this.stationText[i]); + String s = IChatComponent.Serializer.componentToJson(this.stationText[i]); compound.setString("StationText" + (i + 1), s); } for (int i = 0; i < 2; ++i) { - String s = ITextComponent.Serializer.componentToJson(this.nextText[i]); + String s = IChatComponent.Serializer.componentToJson(this.nextText[i]); compound.setString("NextText" + (i + 1), s); } } @@ -130,13 +129,13 @@ public void readFromNBT(NBTTagCompound compound) for (int i = 0; i < 2; ++i) { String s = compound.getString("StationText" + (i + 1)); - ITextComponent ichatcomponent = ITextComponent.Serializer.jsonToComponent(s); + IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s); this.stationText[i] = ichatcomponent; } for (int i = 0; i < 2; ++i) { String s = compound.getString("NextText" + (i + 1)); - ITextComponent ichatcomponent = ITextComponent.Serializer.jsonToComponent(s); + IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s); this.nextText[i] = ichatcomponent; } this.patternList = null; @@ -153,7 +152,7 @@ public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); - return new SPacketUpdateTileEntity(this.pos, 6, nbttagcompound); + return new S35PacketUpdateTileEntity(this.pos, 6, nbttagcompound); } /** diff --git a/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityWHPF.java b/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityWHPF.java index 23999c1..7117ebc 100644 --- a/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityWHPF.java +++ b/src/main/java/io/github/cvronmin/railwayp/tileentity/TileEntityWHPF.java @@ -4,22 +4,21 @@ import com.google.common.collect.Lists; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.Packet; -import net.minecraft.network.play.server.SPacketUpdateTileEntity; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntityBanner; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class TileEntityWHPF extends TileEntityBanner { - public final ITextComponent[] signText = new ITextComponent[] { new TextComponentString(""), - new TextComponentString("") }; + public final IChatComponent[] signText = new IChatComponent[] { new ChatComponentText(""), + new ChatComponentText("") }; private int baseColor; private boolean field_175119_g; /** A list of all patterns stored on this banner. */ @@ -80,7 +79,7 @@ public void setItemValues(ItemStack stack) { if (nbttagcompound.hasKey("Text" + (i + 1))) { String s = nbttagcompound.getString("Text" + (i + 1)); - ITextComponent ichatcomponent = ITextComponent.Serializer.jsonToComponent(s); + IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s); this.signText[i] = ichatcomponent; } @@ -108,7 +107,7 @@ public void writeToNBT(NBTTagCompound compound) { } compound.setShort("Rotation", truebearing > 359 ? 359 : (truebearing < 0 ? 0 : truebearing)); for (int i = 0; i < 2; ++i) { - String s = ITextComponent.Serializer.componentToJson(this.signText[i]); + String s = IChatComponent.Serializer.componentToJson(this.signText[i]); compound.setString("Text" + (i + 1), s); } } @@ -127,7 +126,7 @@ public void readFromNBT(NBTTagCompound compound) { for (int i = 0; i < 2; ++i) { String s = compound.getString("Text" + (i + 1)); - ITextComponent ichatcomponent = ITextComponent.Serializer.jsonToComponent(s); + IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s); this.signText[i] = ichatcomponent; } @@ -145,7 +144,7 @@ public void readFromNBT(NBTTagCompound compound) { public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); - return new SPacketUpdateTileEntity(this.pos, 6, nbttagcompound); + return new S35PacketUpdateTileEntity(this.pos, 6, nbttagcompound); } public short getRotation(){ return truebearing > 359 ? 359 : (truebearing < 0 ? 0 : truebearing); @@ -314,8 +313,8 @@ public void setData(int pn, byte dir, short rotation, String color, String t1, S this.direction = dir; truebearing = rotation; this.routeColorEncoded = color; - this.signText[0] = new TextComponentString(t1); - this.signText[1] = new TextComponentString(t2); + this.signText[0] = new ChatComponentText(t1); + this.signText[1] = new ChatComponentText(t2); decodeColor(); } } diff --git a/src/main/java/io/github/cvronmin/railwayp/util/NTUtil.java b/src/main/java/io/github/cvronmin/railwayp/util/NTUtil.java index 4917097..6c516ea 100644 --- a/src/main/java/io/github/cvronmin/railwayp/util/NTUtil.java +++ b/src/main/java/io/github/cvronmin/railwayp/util/NTUtil.java @@ -17,7 +17,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.BlockPos; +import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.network.ByteBufUtils; diff --git a/src/main/resources/assets/railwayp/blockstates/platform_glass.json b/src/main/resources/assets/railwayp/blockstates/platform_glass.json index 6e696b8..824b190 100644 --- a/src/main/resources/assets/railwayp/blockstates/platform_glass.json +++ b/src/main/resources/assets/railwayp/blockstates/platform_glass.json @@ -1,29 +1,20 @@ { - "multipart": [ - { "apply": { "model": "railwayp:pfglass_post" }}, - { "when": { "north": true }, - "apply": { "model": "railwayp:pfglass_side" } - }, - { "when": { "east": true }, - "apply": { "model": "railwayp:pfglass_side", "y": 90 } - }, - { "when": { "south": true }, - "apply": { "model": "railwayp:pfglass_side_alt" } - }, - { "when": { "west": true }, - "apply": { "model": "railwayp:pfglass_side_alt", "y": 90 } - }, - { "when": { "north": false }, - "apply": { "model": "railwayp:pfglass_noside" } - }, - { "when": { "east": false }, - "apply": { "model": "railwayp:pfglass_noside_alt" } - }, - { "when": { "south": false }, - "apply": { "model": "railwayp:pfglass_noside_alt", "y": 90 } - }, - { "when": { "west": false }, - "apply": { "model": "railwayp:pfglass_noside", "y": 270 } - } - ] + "variants": { + "east=false,north=false,south=false,west=false": { "model": "railwayp:pfglass_nsew" }, + "east=false,north=true,south=false,west=false": { "model": "railwayp:pfglass_n" }, + "east=true,north=false,south=false,west=false": { "model": "railwayp:pfglass_n", "y": 90 }, + "east=false,north=false,south=true,west=false": { "model": "railwayp:pfglass_n", "y": 180 }, + "east=false,north=false,south=false,west=true": { "model": "railwayp:pfglass_n", "y": 270 }, + "east=true,north=true,south=false,west=false": { "model": "railwayp:pfglass_ne" }, + "east=true,north=false,south=true,west=false": { "model": "railwayp:pfglass_ne", "y": 90 }, + "east=false,north=false,south=true,west=true": { "model": "railwayp:pfglass_ne", "y": 180 }, + "east=false,north=true,south=false,west=true": { "model": "railwayp:pfglass_ne", "y": 270 }, + "east=false,north=true,south=true,west=false": { "model": "railwayp:pfglass_ns" }, + "east=true,north=false,south=false,west=true": { "model": "railwayp:pfglass_ns", "y": 90 }, + "east=true,north=true,south=true,west=false": { "model": "railwayp:pfglass_nse" }, + "east=true,north=false,south=true,west=true": { "model": "railwayp:pfglass_nse", "y": 90 }, + "east=false,north=true,south=true,west=true": { "model": "railwayp:pfglass_nse", "y": 180 }, + "east=true,north=true,south=false,west=true": { "model": "railwayp:pfglass_nse", "y": 270 }, + "east=true,north=true,south=true,west=true": { "model": "railwayp:pfglass_nsew" } + } } diff --git a/src/main/resources/assets/railwayp/blockstates/rail_noticer.json b/src/main/resources/assets/railwayp/blockstates/rail_noticer.json index 4001e52..403faa0 100644 --- a/src/main/resources/assets/railwayp/blockstates/rail_noticer.json +++ b/src/main/resources/assets/railwayp/blockstates/rail_noticer.json @@ -1,16 +1,16 @@ -{ - "variants": { - "powered=false,shape=north_south": { "model": "railwayp:noticer_rail_flat" }, - "powered=false,shape=east_west": { "model": "railwayp:noticer_rail_flat", "y": 90 }, - "powered=false,shape=ascending_east": { "model": "railwayp:noticer_rail_raised_ne", "y": 90 }, - "powered=false,shape=ascending_west": { "model": "railwayp:noticer_rail_raised_sw", "y": 90 }, - "powered=false,shape=ascending_north": { "model": "railwayp:noticer_rail_raised_ne" }, - "powered=false,shape=ascending_south": { "model": "railwayp:noticer_rail_raised_sw" }, - "powered=true,shape=north_south": { "model": "railwayp:noticer_rail_active_flat" }, - "powered=true,shape=east_west": { "model": "railwayp:noticer_rail_active_flat", "y": 90 }, - "powered=true,shape=ascending_east": { "model": "railwayp:noticer_rail_active_raised_ne", "y": 90 }, - "powered=true,shape=ascending_west": { "model": "railwayp:noticer_rail_active_raised_sw", "y": 90 }, - "powered=true,shape=ascending_north": { "model": "railwayp:noticer_rail_active_raised_ne" }, - "powered=true,shape=ascending_south": { "model": "railwayp:noticer_rail_active_raised_sw" } - } -} +{ + "variants": { + "powered=false,shape=north_south": { "model": "railwayp:noticer_rail_flat" }, + "powered=false,shape=east_west": { "model": "railwayp:noticer_rail_flat", "y": 90 }, + "powered=false,shape=ascending_east": { "model": "railwayp:noticer_rail_raised_ne", "y": 90 }, + "powered=false,shape=ascending_west": { "model": "railwayp:noticer_rail_raised_sw", "y": 90 }, + "powered=false,shape=ascending_north": { "model": "railwayp:noticer_rail_raised_ne" }, + "powered=false,shape=ascending_south": { "model": "railwayp:noticer_rail_raised_sw" }, + "powered=true,shape=north_south": { "model": "railwayp:noticer_rail_active_flat" }, + "powered=true,shape=east_west": { "model": "railwayp:noticer_rail_active_flat", "y": 90 }, + "powered=true,shape=ascending_east": { "model": "railwayp:noticer_rail_active_raised_ne", "y": 90 }, + "powered=true,shape=ascending_west": { "model": "railwayp:noticer_rail_active_raised_sw", "y": 90 }, + "powered=true,shape=ascending_north": { "model": "railwayp:noticer_rail_active_raised_ne" }, + "powered=true,shape=ascending_south": { "model": "railwayp:noticer_rail_active_raised_sw" } + } +} diff --git a/src/main/resources/assets/railwayp/blockstates/roof_whpf.json b/src/main/resources/assets/railwayp/blockstates/roof_whpf.json index 7f53171..e58a60e 100644 --- a/src/main/resources/assets/railwayp/blockstates/roof_whpf.json +++ b/src/main/resources/assets/railwayp/blockstates/roof_whpf.json @@ -1,5 +1,5 @@ -{ - "variants": { - "normal":{"model":"railwayp:roof_whpf"} - } +{ + "variants": { + "normal":{"model":"railwayp:roof_whpf"} + } } \ No newline at end of file diff --git a/src/main/resources/assets/railwayp/blockstates/wall_name_banner.json b/src/main/resources/assets/railwayp/blockstates/wall_name_banner.json index 06184e9..2b0bfc5 100644 --- a/src/main/resources/assets/railwayp/blockstates/wall_name_banner.json +++ b/src/main/resources/assets/railwayp/blockstates/wall_name_banner.json @@ -1,8 +1,8 @@ -{ - "variants": { - "facing=north":{"model": "railwayp:wall_platform_banner"}, - "facing=south":{"model": "railwayp:wall_platform_banner"}, - "facing=west":{"model": "railwayp:wall_platform_banner"}, - "facing=east":{"model": "railwayp:wall_platform_banner"} - } +{ + "variants": { + "facing=north":{"model": "railwayp:wall_platform_banner"}, + "facing=south":{"model": "railwayp:wall_platform_banner"}, + "facing=west":{"model": "railwayp:wall_platform_banner"}, + "facing=east":{"model": "railwayp:wall_platform_banner"} + } } \ No newline at end of file diff --git a/src/main/resources/assets/railwayp/blockstates/wall_platform_banner.json b/src/main/resources/assets/railwayp/blockstates/wall_platform_banner.json index 06184e9..2b0bfc5 100644 --- a/src/main/resources/assets/railwayp/blockstates/wall_platform_banner.json +++ b/src/main/resources/assets/railwayp/blockstates/wall_platform_banner.json @@ -1,8 +1,8 @@ -{ - "variants": { - "facing=north":{"model": "railwayp:wall_platform_banner"}, - "facing=south":{"model": "railwayp:wall_platform_banner"}, - "facing=west":{"model": "railwayp:wall_platform_banner"}, - "facing=east":{"model": "railwayp:wall_platform_banner"} - } +{ + "variants": { + "facing=north":{"model": "railwayp:wall_platform_banner"}, + "facing=south":{"model": "railwayp:wall_platform_banner"}, + "facing=west":{"model": "railwayp:wall_platform_banner"}, + "facing=east":{"model": "railwayp:wall_platform_banner"} + } } \ No newline at end of file diff --git a/src/main/resources/assets/railwayp/blockstates/wall_route_sign.json b/src/main/resources/assets/railwayp/blockstates/wall_route_sign.json index 76a3eef..71e0e93 100644 --- a/src/main/resources/assets/railwayp/blockstates/wall_route_sign.json +++ b/src/main/resources/assets/railwayp/blockstates/wall_route_sign.json @@ -1,8 +1,8 @@ -{ - "variants": { - "facing=north":{"model": "railwayp:wall_route_sign"}, - "facing=south":{"model": "railwayp:wall_route_sign"}, - "facing=west":{"model": "railwayp:wall_route_sign"}, - "facing=east":{"model": "railwayp:wall_route_sign"} - } +{ + "variants": { + "facing=north":{"model": "railwayp:wall_route_sign"}, + "facing=south":{"model": "railwayp:wall_route_sign"}, + "facing=west":{"model": "railwayp:wall_route_sign"}, + "facing=east":{"model": "railwayp:wall_route_sign"} + } } \ No newline at end of file diff --git a/src/main/resources/assets/railwayp/blockstates/wall_whpf.json b/src/main/resources/assets/railwayp/blockstates/wall_whpf.json index f954eee..013cec0 100644 --- a/src/main/resources/assets/railwayp/blockstates/wall_whpf.json +++ b/src/main/resources/assets/railwayp/blockstates/wall_whpf.json @@ -1,8 +1,8 @@ -{ - "variants": { - "facing=north":{"model": "railwayp:wall_whpf"}, - "facing=south":{"model": "railwayp:wall_whpf"}, - "facing=west":{"model": "railwayp:wall_whpf"}, - "facing=east":{"model": "railwayp:wall_whpf"} - } +{ + "variants": { + "facing=north":{"model": "railwayp:wall_whpf"}, + "facing=south":{"model": "railwayp:wall_whpf"}, + "facing=west":{"model": "railwayp:wall_whpf"}, + "facing=east":{"model": "railwayp:wall_whpf"} + } } \ No newline at end of file diff --git a/src/main/resources/assets/railwayp/models/block/pfdoor_extension.json b/src/main/resources/assets/railwayp/models/block/pfdoor_extension.json index 8d705a9..49fccb5 100644 --- a/src/main/resources/assets/railwayp/models/block/pfdoor_extension.json +++ b/src/main/resources/assets/railwayp/models/block/pfdoor_extension.json @@ -1,6 +1,6 @@ -{ - "parent": "block/cube_all", - "textures": { - "all": "missingno" - } -} +{ + "parent": "block/cube_all", + "textures": { + "all": "missingno" + } +} diff --git a/src/main/resources/assets/railwayp/models/block/pfglass_n.json b/src/main/resources/assets/railwayp/models/block/pfglass_n.json new file mode 100644 index 0000000..cf32dd2 --- /dev/null +++ b/src/main/resources/assets/railwayp/models/block/pfglass_n.json @@ -0,0 +1,22 @@ +{ + "ambientocclusion": false, + "textures": { + "side":"railwayp:blocks/pfdoor_side", + "edge":"railwayp:blocks/pfdoor_edge", + "particle": "#side" + }, + "elements": [ + { "from": [ 6.4, 0, 0 ], + "to": [ 9.6, 16, 9.6 ], + "shade": false, + "faces": { + "down": { "uv": [ 6.4, 0, 9.6, 9.6 ], "texture": "#edge" }, + "up": { "uv": [ 6.4, 0, 9.6, 9.6 ], "texture": "#edge" }, + "north": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge", "cullface": "north" }, + "south": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge" }, + "west": { "uv": [ 7, 0, 16, 16 ], "texture": "#side" }, + "east": { "uv": [ 7, 0, 16, 16 ], "texture": "#side" } + } + } + ] +} diff --git a/src/main/resources/assets/railwayp/models/block/pfglass_ne.json b/src/main/resources/assets/railwayp/models/block/pfglass_ne.json new file mode 100644 index 0000000..65eefa4 --- /dev/null +++ b/src/main/resources/assets/railwayp/models/block/pfglass_ne.json @@ -0,0 +1,34 @@ +{ + "ambientocclusion": false, + "textures": { + "side":"railwayp:blocks/pfdoor_side", + "edge":"railwayp:blocks/pfdoor_edge", + "particle": "#side" + }, + "elements": [ + { "from": [ 6.4, 0, 0 ], + "to": [ 9.6, 16, 9.6 ], + "shade": false, + "faces": { + "down": { "uv": [ 6.4, 0, 9.6, 9.6 ], "texture": "#edge" }, + "up": { "uv": [ 6.4, 0, 9.6, 9.6 ], "texture": "#edge" }, + "north": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge", "cullface": "north" }, + "south": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge" }, + "west": { "uv": [ 7, 0, 16, 16 ], "texture": "#side" }, + "east": { "uv": [ 16, 0, 7, 16 ], "texture": "#side" } + } + }, + { "from": [ 9.6, 0, 6.4 ], + "to": [ 16, 16, 9.6 ], + "shade": false, + "faces": { + "down": { "uv": [ 6.4, 9.6, 9.6, 16 ], "rotation": 90, "texture": "#edge" }, + "up": { "uv": [ 6.4, 9.6, 9.6, 16 ], "rotation": 90, "texture": "#edge" }, + "north": { "uv": [ 9.6, 0, 16, 16 ], "texture": "#side" }, + "south": { "uv": [ 9.6, 0, 16, 16 ], "texture": "#side" }, + "west": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#side" }, + "east": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge", "cullface": "east" } + } + } + ] +} diff --git a/src/main/resources/assets/railwayp/models/block/pfglass_ns.json b/src/main/resources/assets/railwayp/models/block/pfglass_ns.json new file mode 100644 index 0000000..37ea42f --- /dev/null +++ b/src/main/resources/assets/railwayp/models/block/pfglass_ns.json @@ -0,0 +1,22 @@ +{ + "ambientocclusion": false, + "textures": { + "side":"railwayp:blocks/pfdoor_side", + "edge":"railwayp:blocks/pfdoor_edge", + "particle": "#side" + }, + "elements": [ + { "from": [ 6.4, 0, 0 ], + "to": [ 9.6, 16, 16 ], + "shade": false, + "faces": { + "down": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge", "cull": false }, + "up": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge", "cull": false }, + "north": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge" }, + "south": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge" }, + "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#side", "cull": false }, + "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#side", "cull": false } + } + } + ] +} diff --git a/src/main/resources/assets/railwayp/models/block/pfglass_nse.json b/src/main/resources/assets/railwayp/models/block/pfglass_nse.json new file mode 100644 index 0000000..4a9e1fe --- /dev/null +++ b/src/main/resources/assets/railwayp/models/block/pfglass_nse.json @@ -0,0 +1,34 @@ +{ + "ambientocclusion": false, + "textures": { + "side":"railwayp:blocks/pfdoor_side", + "edge":"railwayp:blocks/pfdoor_edge", + "particle": "#side" + }, + "elements": [ + { "from": [ 6.4, 0, 0 ], + "to": [ 9.6, 16, 16 ], + "shade": false, + "faces": { + "down": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge" }, + "up": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge" }, + "north": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge", "cullface": "north" }, + "south": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge", "cullface": "south" }, + "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#side" }, + "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#side" } + } + }, + { "from": [ 9.6, 0, 6.4 ], + "to": [ 16, 16, 9.6 ], + "shade": false, + "faces": { + "down": { "uv": [ 6.4, 9.6, 9.6, 16 ], "rotation": 90, "texture": "#edge" }, + "up": { "uv": [ 6.4, 9.6, 9.6, 16 ], "rotation": 90, "texture": "#edge" }, + "north": { "uv": [ 9.6, 0, 16, 16 ], "texture": "#side" }, + "south": { "uv": [ 9.6, 0, 16, 16 ], "texture": "#side" }, + "west": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#side" }, + "east": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge", "cullface": "east" } + } + } + ] +} diff --git a/src/main/resources/assets/railwayp/models/block/pfglass_nsew.json b/src/main/resources/assets/railwayp/models/block/pfglass_nsew.json new file mode 100644 index 0000000..1e2a6de --- /dev/null +++ b/src/main/resources/assets/railwayp/models/block/pfglass_nsew.json @@ -0,0 +1,34 @@ +{ + "ambientocclusion": false, + "textures": { + "side":"railwayp:blocks/pfdoor_side", + "edge":"railwayp:blocks/pfdoor_edge", + "particle": "#side" + }, + "elements": [ + { "from": [ 6.4, 0, 0 ], + "to": [ 9.6, 16, 16 ], + "shade": false, + "faces": { + "down": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge" }, + "up": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge" }, + "north": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge", "cullface": "north" }, + "south": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge", "cullface": "south" }, + "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#side" }, + "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#side" } + } + }, + { "from": [ 0, 0, 6.4 ], + "to": [ 16, 16, 9.6 ], + "shade": false, + "faces": { + "down": { "uv": [ 6.4, 0, 9.6, 16 ], "rotation": 90, "texture": "#edge" }, + "up": { "uv": [ 6.4, 0, 9.6, 16 ], "rotation": 90, "texture": "#edge" }, + "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#side" }, + "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#side" }, + "west": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge", "cullface": "west" }, + "east": { "uv": [ 6.4, 0, 9.6, 16 ], "texture": "#edge", "cullface": "east" } + } + } + ] +} diff --git a/src/main/resources/assets/railwayp/models/block/roof_whpf.json b/src/main/resources/assets/railwayp/models/block/roof_whpf.json index 8d705a9..49fccb5 100644 --- a/src/main/resources/assets/railwayp/models/block/roof_whpf.json +++ b/src/main/resources/assets/railwayp/models/block/roof_whpf.json @@ -1,6 +1,6 @@ -{ - "parent": "block/cube_all", - "textures": { - "all": "missingno" - } -} +{ + "parent": "block/cube_all", + "textures": { + "all": "missingno" + } +} diff --git a/src/main/resources/assets/railwayp/models/block/wall_platform_banner.json b/src/main/resources/assets/railwayp/models/block/wall_platform_banner.json index 8d705a9..49fccb5 100644 --- a/src/main/resources/assets/railwayp/models/block/wall_platform_banner.json +++ b/src/main/resources/assets/railwayp/models/block/wall_platform_banner.json @@ -1,6 +1,6 @@ -{ - "parent": "block/cube_all", - "textures": { - "all": "missingno" - } -} +{ + "parent": "block/cube_all", + "textures": { + "all": "missingno" + } +} diff --git a/src/main/resources/assets/railwayp/models/block/wall_route_sign.json b/src/main/resources/assets/railwayp/models/block/wall_route_sign.json index 8d705a9..49fccb5 100644 --- a/src/main/resources/assets/railwayp/models/block/wall_route_sign.json +++ b/src/main/resources/assets/railwayp/models/block/wall_route_sign.json @@ -1,6 +1,6 @@ -{ - "parent": "block/cube_all", - "textures": { - "all": "missingno" - } -} +{ + "parent": "block/cube_all", + "textures": { + "all": "missingno" + } +} diff --git a/src/main/resources/assets/railwayp/models/block/wall_whpf.json b/src/main/resources/assets/railwayp/models/block/wall_whpf.json index 8d705a9..49fccb5 100644 --- a/src/main/resources/assets/railwayp/models/block/wall_whpf.json +++ b/src/main/resources/assets/railwayp/models/block/wall_whpf.json @@ -1,6 +1,6 @@ -{ - "parent": "block/cube_all", - "textures": { - "all": "missingno" - } -} +{ + "parent": "block/cube_all", + "textures": { + "all": "missingno" + } +} diff --git a/src/main/resources/assets/railwayp/models/item/editor.json b/src/main/resources/assets/railwayp/models/item/editor.json index c33fbbb..1ab3c83 100644 --- a/src/main/resources/assets/railwayp/models/item/editor.json +++ b/src/main/resources/assets/railwayp/models/item/editor.json @@ -2,5 +2,17 @@ "parent": "item/generated", "textures": { "layer0": "railwayp:items/editor" + }, + "display": { + "thirdperson": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 1, -3 ], + "scale": [ 0.55, 0.55, 0.55 ] + }, + "firstperson": { + "rotation": [ 0, -135, 25 ], + "translation": [ 0, 4, 2 ], + "scale": [ 1.7, 1.7, 1.7 ] + } } } \ No newline at end of file diff --git a/src/main/resources/assets/railwayp/models/item/name_banner.json b/src/main/resources/assets/railwayp/models/item/name_banner.json index 6feeeb6..1b80281 100644 --- a/src/main/resources/assets/railwayp/models/item/name_banner.json +++ b/src/main/resources/assets/railwayp/models/item/name_banner.json @@ -1,6 +1,18 @@ { - "parent": "item/generated", + "parent": "railwayp:builtin/generated", "textures": { "layer0": "railwayp:items/name_banner" + }, + "display": { + "thirdperson": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 1, -3 ], + "scale": [ 0.55, 0.55, 0.55 ] + }, + "firstperson": { + "rotation": [ 0, -135, 25 ], + "translation": [ 0, 4, 2 ], + "scale": [ 1.7, 1.7, 1.7 ] + } } } \ No newline at end of file diff --git a/src/main/resources/assets/railwayp/models/item/platform_banner.json b/src/main/resources/assets/railwayp/models/item/platform_banner.json index ff826b9..3b833c9 100644 --- a/src/main/resources/assets/railwayp/models/item/platform_banner.json +++ b/src/main/resources/assets/railwayp/models/item/platform_banner.json @@ -1,6 +1,18 @@ { - "parent": "item/generated", + "parent": "railwayp:builtin/generated", "textures": { "layer0": "railwayp:items/platform_banner" + }, + "display": { + "thirdperson": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 1, -3 ], + "scale": [ 0.55, 0.55, 0.55 ] + }, + "firstperson": { + "rotation": [ 0, -135, 25 ], + "translation": [ 0, 4, 2 ], + "scale": [ 1.7, 1.7, 1.7 ] + } } } \ No newline at end of file diff --git a/src/main/resources/assets/railwayp/models/item/platform_glass.json b/src/main/resources/assets/railwayp/models/item/platform_glass.json index 9aa7f68..1228ec0 100644 --- a/src/main/resources/assets/railwayp/models/item/platform_glass.json +++ b/src/main/resources/assets/railwayp/models/item/platform_glass.json @@ -1,6 +1,10 @@ { - "parent": "item/generated", - "textures": { - "layer0": "railwayp:blocks/pfdoor_side" + "parent": "railwayp:block/pfglass_ns", + "display": { + "thirdperson": { + "rotation": [ 10, -45, 170 ], + "translation": [ 0, 1.5, -2.75 ], + "scale": [ 0.375, 0.375, 0.375 ] + } } } diff --git a/src/main/resources/assets/railwayp/models/item/rail_noticer.json b/src/main/resources/assets/railwayp/models/item/rail_noticer.json index 156f829..756fb07 100644 --- a/src/main/resources/assets/railwayp/models/item/rail_noticer.json +++ b/src/main/resources/assets/railwayp/models/item/rail_noticer.json @@ -1,6 +1,18 @@ -{ - "parent": "item/generated", - "textures": { - "layer0": "railwayp:blocks/rail_noticer" - } -} +{ + "parent": "item/generated", + "textures": { + "layer0": "railwayp:blocks/rail_noticer" + }, + "display": { + "thirdperson": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 1, -3 ], + "scale": [ 0.55, 0.55, 0.55 ] + }, + "firstperson": { + "rotation": [ 0, -135, 25 ], + "translation": [ 0, 4, 2 ], + "scale": [ 1.7, 1.7, 1.7 ] + } + } +} diff --git a/src/main/resources/assets/railwayp/models/item/route_sign.json b/src/main/resources/assets/railwayp/models/item/route_sign.json index 96cdfe3..2183c22 100644 --- a/src/main/resources/assets/railwayp/models/item/route_sign.json +++ b/src/main/resources/assets/railwayp/models/item/route_sign.json @@ -1,6 +1,18 @@ { - "parent": "item/generated", + "parent": "railwayp:builtin/generated", "textures": { "layer0": "railwayp:items/route_sign" + }, + "display": { + "thirdperson": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 1, -3 ], + "scale": [ 0.55, 0.55, 0.55 ] + }, + "firstperson": { + "rotation": [ 0, -135, 25 ], + "translation": [ 0, 4, 2 ], + "scale": [ 1.7, 1.7, 1.7 ] + } } } \ No newline at end of file diff --git a/src/main/resources/assets/railwayp/models/item/whpf.json b/src/main/resources/assets/railwayp/models/item/whpf.json index e723c48..14619ad 100644 --- a/src/main/resources/assets/railwayp/models/item/whpf.json +++ b/src/main/resources/assets/railwayp/models/item/whpf.json @@ -1,6 +1,18 @@ { - "parent": "item/generated", + "parent": "railwayp:builtin/generated", "textures": { "layer0": "railwayp:items/whpf" + }, + "display": { + "thirdperson": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 1, -3 ], + "scale": [ 0.55, 0.55, 0.55 ] + }, + "firstperson": { + "rotation": [ 0, -135, 25 ], + "translation": [ 0, 4, 2 ], + "scale": [ 1.7, 1.7, 1.7 ] + } } }