Jump to content

grim3212

Members
  • Posts

    13
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

grim3212's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Well, I think that might end up being more work than it is worth. I think I will leave it as it is right now. Or I might try and update this https://github.com/MinecraftForge/MinecraftForge/pull/2009 and support desert wells. EDIT: Updated version can be found https://github.com/MinecraftForge/MinecraftForge/pull/3120
  2. Hello, so I am trying to replace desert wells. I am having trouble stopping vanilla wells to spawn though. I have been looking through the events in terraingen but haven't been able to stop them from still being generating. I am able to replace BiomeDesert's biome decorator with a custom one which just spawns in the new wells but as far as I can tell a Biomes decorate method doesn't trigger an event. I have also looked into a PopulateChunkEvent but I am not sure how this would be able to replace them. Any help is appreciated I am trying to get rid of the ASM I have been using previously.
  3. I am pretty sure I got it figured out for the most part. Added an edit for what I changed.
  4. Okay, so I am trying to update some of my mods and have everything going except for the dynamic textures on a few blocks. These blocks pretty much allow to take on the texture of any block. I have been messing around for a bit and I was able to get the models to show up but not the textures applied to the blocks so now I am trying another route with a custommodelloader. But, getQuads gets stuck in an infinite loop and I am not sure how else it would work. I am not even sure if this is necessary because all I want is to be able to retexture the model not change the model itself. In 1.8.9 I just would return a modified Builder from SimpleBakedModel but I don't have access to a blockstate now. So I am open to ideas. Thanks! IModel and CustomModelLoader package com.grim3212.mc.pack.decor.client.model; import java.io.IOException; import java.util.Collection; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.grim3212.mc.pack.GrimPack; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.resources.IResourceManager; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.ICustomModelLoader; import net.minecraftforge.client.model.IModel; import net.minecraftforge.client.model.IPerspectiveAwareModel; import net.minecraftforge.client.model.IRetexturableModel; import net.minecraftforge.common.model.IModelState; import net.minecraftforge.common.model.TRSRTransformation; public class FurnitureModel implements IRetexturableModel { public static final FurnitureModel MODEL = new FurnitureModel(); private final ResourceLocation textureLocation; public FurnitureModel() { this(null); } public FurnitureModel(ResourceLocation textureLocation) { this.textureLocation = textureLocation; } @Override public Collection<ResourceLocation> getDependencies() { return ImmutableList.of(); } @Override public Collection<ResourceLocation> getTextures() { ImmutableSet.Builder<ResourceLocation> builder = ImmutableSet.builder(); if (textureLocation != null) builder.add(textureLocation); return builder.build(); } @Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transformMap = IPerspectiveAwareModel.MapWrapper.getTransforms(state); TextureAtlasSprite base = null; if (textureLocation != null) base = bakedTextureGetter.apply(textureLocation); return new BakedFurnitureModel(this, base, format, transformMap); } @Override public IModelState getDefaultState() { return TRSRTransformation.identity(); } @Override public IModel retexture(ImmutableMap<String, String> textures) { ResourceLocation base = textureLocation; if (textures.containsKey("texture")) base = new ResourceLocation(textures.get("texture")); return new FurnitureModel(base); } public static enum FurnitureModelLoader implements ICustomModelLoader { instance; @Override public boolean accepts(ResourceLocation modelLocation) { return modelLocation.getResourceDomain().equals(GrimPack.modID) && modelLocation.getResourcePath().contains("custom_counter"); } @Override public IModel loadModel(ResourceLocation modelLocation) throws IOException { System.out.println("Accepted: " + modelLocation); return MODEL; } @Override public void onResourceManagerReload(IResourceManager resourceManager) { } } } BakedModel package com.grim3212.mc.pack.decor.client.model; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.vecmath.Matrix4f; import org.apache.commons.lang3.tuple.Pair; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.grim3212.mc.pack.core.util.NBTHelper; import com.grim3212.mc.pack.decor.block.BlockTextured; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BlockModelShapes; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.block.model.ItemOverride; import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.resources.IResourceManagerReloadListener; import net.minecraft.entity.EntityLivingBase; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import net.minecraftforge.client.model.IModel; import net.minecraftforge.client.model.IPerspectiveAwareModel; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.client.model.ModelProcessingHelper; import net.minecraftforge.client.model.SimpleModelState; import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.common.property.IExtendedBlockState; public class BakedFurnitureModel implements IPerspectiveAwareModel, IResourceManagerReloadListener { private final IModel model; private final ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms; private final TextureAtlasSprite particle; private final VertexFormat format; public BakedFurnitureModel(IModel model, TextureAtlasSprite particle, VertexFormat fmt, ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms) { this.model = model; this.particle = particle; this.format = fmt; this.transforms = transforms; } @Override public void onResourceManagerReload(IResourceManager resourceManager) { this.cache.clear(); } @Override public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) { if (state instanceof IExtendedBlockState) { IExtendedBlockState exState = (IExtendedBlockState) state; if (exState.getValue(BlockTextured.BLOCKID) != null && exState.getValue(BlockTextured.BLOCKMETA) != null) { int blockID = exState.getValue(BlockTextured.BLOCKID); int blockMeta = exState.getValue(BlockTextured.BLOCKMETA); return this.getCachedModel(blockID, blockMeta).getQuads(state, side, rand); } } return ImmutableList.of(); } private final Map<List<Integer>, IBakedModel> cache = new HashMap<List<Integer>, IBakedModel>(); public IBakedModel getCachedModel(int blockID, int blockMeta) { List<Integer> key = Arrays.asList(blockID, blockMeta); if (!this.cache.containsKey(key)) { ImmutableMap.Builder<String, String> newTexture = ImmutableMap.builder(); if (Block.getBlockById(blockID) == Blocks.GRASS) { newTexture.put("texture", "minecraft:blocks/grass_top"); } else if (Block.getBlockById(blockID) == Blocks.DIRT && blockMeta == 2) { newTexture.put("texture", "minecraft:blocks/dirt_podzol_top"); } else if (Block.getBlockById(blockID) == Blocks.MYCELIUM) { newTexture.put("texture", "minecraft:blocks/mycelium_top"); } else { BlockModelShapes blockModel = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes(); IBlockState blockState = Block.getBlockById(blockID).getStateFromMeta(blockMeta); TextureAtlasSprite blockTexture = blockModel.getTexture(blockState); newTexture.put("texture", blockTexture.getIconName()); } System.out.println("Adding to cache " + key); this.cache.put(key, ModelProcessingHelper.retexture(model, newTexture.build()).bake(new SimpleModelState(transforms), format, ModelLoader.defaultTextureGetter())); } System.out.println(key); return this.cache.get(key); } @Override public boolean isAmbientOcclusion() { return true; } @Override public boolean isGui3d() { return true; } @Override public boolean isBuiltInRenderer() { return false; } @Override public TextureAtlasSprite getParticleTexture() { return particle; } @Override public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; } @Override public ItemOverrideList getOverrides() { return itemHandler; } private final ItemOverrideList itemHandler = new ItemOverrideList(Lists.<ItemOverride> newArrayList()) { @Override public IBakedModel handleItemState(IBakedModel model, ItemStack stack, World world, EntityLivingBase entity) { if (stack.hasTagCompound() && stack.getTagCompound().hasKey("blockID") && stack.getTagCompound().hasKey("blockMeta")) { int blockID = NBTHelper.getInt(stack, "blockID"); int blockMeta = NBTHelper.getInt(stack, "blockMeta"); return BakedFurnitureModel.this.getCachedModel(blockID, blockMeta); } return BakedFurnitureModel.this; } }; @Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return MapWrapper.handlePerspective(this, transforms, cameraTransformType); } } EDIT: Well I was able to get it working. Might not be the most efficient way though. So what I did was modify the ICustomModelLoader to include the related block model needed for each loaded modelLocation. In bake I would return instead of the IModel itself that location and the texturelocation set. In the getCachedModel I get the model using [embed=425,349]ModelLoaderRegistry.getModelOrMissing[/embed] then use [embed=425,349]ModelProcessingHelper.retexture[/embed] to re-texture the elements that need to be re-textured and then finally bake the model and add it to the cache. Like I said I am not sure if this is the best way to achieve this result but it is working but I am always open to ideas.
  5. Alright, I am really sorry about the code. I should have cleaned it up before I was asking for help but I totally forgot. Anyway I ended up solving it. These double d3 = (double) k.getMinU(); double d4 = (double) k.getMinV(); double d5 = (double) k.getMaxU(); double d6 = (double) k.getMaxV(); Should be like this... I had them flipped around. double d3 = (double) k.getMinU(); double d4 = (double) k.getMaxU(); double d5 = (double) k.getMinV(); double d6 = (double) k.getMaxV(); But I did look into the lighting like you said and you were right... It was not doing what I wanted so I now have that working too. But everything is now fixed so thank you!
  6. I am working on a new block which uses ISimpleBlockRenderingHandler and this one is having issues. For some reason it is pulling in textures from other blocks and not using the textures I have for it at all. I am not really sure what is going on but here is a picture. I'm pretty sure it has something to do with these lines. Tessellator tessellator = Tessellator.instance; IIcon k = block.getIcon(0, i); if (overrideBlockTexture != null) { k = overrideBlockTexture; } double d3 = (double) k.getMinU(); double d4 = (double) k.getMinV(); double d5 = (double) k.getMaxU(); double d6 = (double) k.getMaxV(); But here is the whole file just in case. package grim3212.mc.spikes; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderSpike implements ISimpleBlockRenderingHandler { @Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { if (modelId == Spikes.spikeRenderID && block == Spikes.spike) { Tessellator tessellator = Tessellator.instance; float f = block.getMixedBrightnessForBlock(world, x, y, z); tessellator.setColorOpaque_F(f, f, f); renderSpike((BlockSpike) block, world.getBlockMetadata(x, y, z), x, y, z, renderer.overrideBlockTexture); return true; } else { return false; } } @Override public boolean shouldRender3DInInventory(int modelId) { return false; } @Override public int getRenderId() { return Spikes.spikeRenderID; } public static void renderSpike(BlockSpike block, int i, double d, double d1, double d2, IIcon overrideBlockTexture) { Tessellator tessellator = Tessellator.instance; IIcon k = block.getIcon(0, i); if (overrideBlockTexture != null) { k = overrideBlockTexture; } double d3 = (double) k.getMinU(); double d4 = (double) k.getMinV(); double d5 = (double) k.getMaxU(); double d6 = (double) k.getMaxV(); if (i == 6 || i == 12 || i == 4 || i == 10 || i == 2 || i == { double d7 = 0.0D; d7 = d3; d3 = d4; d4 = d7; d7 = d5; d5 = d6; d6 = d7; } double d8 = (d + 0.5D) - 0.44999998807907104D; double d9 = d + 0.5D + 0.44999998807907104D; double d10 = (d2 + 0.5D) - 0.44999998807907104D; double d11 = d2 + 0.5D + 0.44999998807907104D; double d12 = (d1 + 0.5D) - 0.44999998807907104D; double d13 = d1 + 0.5D + 0.44999998807907104D; if (i == 1 || i == 6 || i == 7 || i == 12) { tessellator.addVertexWithUV(d8, d1 + 1.0D, d10, d3, d5); tessellator.addVertexWithUV(d8, d1 + 0.0D, d10, d3, d6); tessellator.addVertexWithUV(d9, d1 + 0.0D, d11, d4, d6); tessellator.addVertexWithUV(d9, d1 + 1.0D, d11, d4, d5); tessellator.addVertexWithUV(d9, d1 + 1.0D, d11, d3, d5); tessellator.addVertexWithUV(d9, d1 + 0.0D, d11, d3, d6); tessellator.addVertexWithUV(d8, d1 + 0.0D, d10, d4, d6); tessellator.addVertexWithUV(d8, d1 + 1.0D, d10, d4, d5); tessellator.addVertexWithUV(d8, d1 + 1.0D, d11, d3, d5); tessellator.addVertexWithUV(d8, d1 + 0.0D, d11, d3, d6); tessellator.addVertexWithUV(d9, d1 + 0.0D, d10, d4, d6); tessellator.addVertexWithUV(d9, d1 + 1.0D, d10, d4, d5); tessellator.addVertexWithUV(d9, d1 + 1.0D, d10, d3, d5); tessellator.addVertexWithUV(d9, d1 + 0.0D, d10, d3, d6); tessellator.addVertexWithUV(d8, d1 + 0.0D, d11, d4, d6); tessellator.addVertexWithUV(d8, d1 + 1.0D, d11, d4, d5); } else if (i == 4 || i == 10 || i == 5 || i == 11) { tessellator.addVertexWithUV(d + 1.0D, d12, d10, d3, d5); tessellator.addVertexWithUV(d + 0.0D, d12, d10, d3, d6); tessellator.addVertexWithUV(d + 0.0D, d13, d11, d4, d6); tessellator.addVertexWithUV(d + 1.0D, d13, d11, d4, d5); tessellator.addVertexWithUV(d + 1.0D, d13, d11, d3, d5); tessellator.addVertexWithUV(d + 0.0D, d13, d11, d3, d6); tessellator.addVertexWithUV(d + 0.0D, d12, d10, d4, d6); tessellator.addVertexWithUV(d + 1.0D, d12, d10, d4, d5); tessellator.addVertexWithUV(d + 1.0D, d12, d11, d3, d5); tessellator.addVertexWithUV(d + 0.0D, d12, d11, d3, d6); tessellator.addVertexWithUV(d + 0.0D, d13, d10, d4, d6); tessellator.addVertexWithUV(d + 1.0D, d13, d10, d4, d5); tessellator.addVertexWithUV(d + 1.0D, d13, d10, d3, d5); tessellator.addVertexWithUV(d + 0.0D, d13, d10, d3, d6); tessellator.addVertexWithUV(d + 0.0D, d12, d11, d4, d6); tessellator.addVertexWithUV(d + 1.0D, d12, d11, d4, d5); } else if (i == 2 || i == 8 || i == 3 || i == 9) { tessellator.addVertexWithUV(d8, d12, d2 + 1.0D, d3, d5); tessellator.addVertexWithUV(d8, d12, d2 + 0.0D, d3, d6); tessellator.addVertexWithUV(d9, d13, d2 + 0.0D, d4, d6); tessellator.addVertexWithUV(d9, d13, d2 + 1.0D, d4, d5); tessellator.addVertexWithUV(d9, d13, d2 + 1.0D, d3, d5); tessellator.addVertexWithUV(d9, d13, d2 + 0.0D, d3, d6); tessellator.addVertexWithUV(d8, d12, d2 + 0.0D, d4, d6); tessellator.addVertexWithUV(d8, d12, d2 + 1.0D, d4, d5); tessellator.addVertexWithUV(d8, d13, d2 + 1.0D, d3, d5); tessellator.addVertexWithUV(d8, d13, d2 + 0.0D, d3, d6); tessellator.addVertexWithUV(d9, d12, d2 + 0.0D, d4, d6); tessellator.addVertexWithUV(d9, d12, d2 + 1.0D, d4, d5); tessellator.addVertexWithUV(d9, d12, d2 + 1.0D, d3, d5); tessellator.addVertexWithUV(d9, d12, d2 + 0.0D, d3, d6); tessellator.addVertexWithUV(d8, d13, d2 + 0.0D, d4, d6); tessellator.addVertexWithUV(d8, d13, d2 + 1.0D, d4, d5); } } } Thanks EDIT: This has been solved This double d3 = (double) k.getMinU(); double d4 = (double) k.getMinV(); double d5 = (double) k.getMaxU(); double d6 = (double) k.getMaxV(); Should be like this... I had them flipped around. double d3 = (double) k.getMinU(); double d4 = (double) k.getMaxU(); double d5 = (double) k.getMinV(); double d6 = (double) k.getMaxV();
  7. Well I do have Block.isOpaqueCube set to return false and I also have shouldSideBeRendered to just return true. Also all of the blocks are correct I did check. Well thanks for all the help! I am going to try and see if I can get this working by using Techne models. EDIT: I got everything working with the Techne models... Still weird that the way I had it didn't work. Anyway thanks for helping.
  8. It is kind of working. This is what it looks like before commenting it out. And after which as you can see the part is rendering correctly but should be the bottom piece. But if I place one in a two block radius then this happens. I have no idea why this would be happening because their is nothing in the Blocks class checking for anything like this. But anyway here is the renderer that renders each of the which might have something in it. package grim3212.mc.lampposts; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; public class RenderLampPost { private static IIcon texture; public static void setTexture(IIcon var0) { texture = var0; } public static boolean renderBottom(Block var0, int var1, int var2, int var3, RenderBlocks var4) { var4.overrideBlockTexture = texture; var0.setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 0.1F, 0.8F); var4.renderStandardBlock(var0, var1, var2, var3); var4.overrideBlockTexture = texture; var0.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F); var4.renderStandardBlock(var0, var1, var2, var3); var4.overrideBlockTexture = null; return true; } public static boolean renderMiddle(Block var0, int var1, int var2, int var3, RenderBlocks var4) { var4.overrideBlockTexture = texture; var0.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F); var4.renderStandardBlock(var0, var1, var2, var3); var4.overrideBlockTexture = null; return true; } public static boolean renderTop(Block var0, int var1, int var2, int var3, RenderBlocks var4) { var4.overrideBlockTexture = texture; var0.setBlockBounds(0.1F, 0.2F, 0.1F, 0.9F, 0.3F, 0.9F); var4.renderStandardBlock(var0, var1, var2, var3); var4.overrideBlockTexture = texture; var0.setBlockBounds(0.1F, 0.9F, 0.1F, 0.9F, 1.0F, 0.9F); var4.renderStandardBlock(var0, var1, var2, var3); var4.overrideBlockTexture = texture; var0.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 0.2F, 0.625F); var4.renderStandardBlock(var0, var1, var2, var3); var4.overrideBlockTexture = null; var4.overrideBlockTexture = texture; var0.setBlockBounds(0.1F, 0.3F, 0.1F, 0.2F, 0.9F, 0.2F); var4.renderStandardBlock(var0, var1, var2, var3); var4.overrideBlockTexture = texture; var0.setBlockBounds(0.8F, 0.3F, 0.8F, 0.9F, 0.9F, 0.9F); var4.renderStandardBlock(var0, var1, var2, var3); var4.overrideBlockTexture = texture; var0.setBlockBounds(0.8F, 0.3F, 0.1F, 0.9F, 0.9F, 0.2F); var4.renderStandardBlock(var0, var1, var2, var3); var4.overrideBlockTexture = texture; var0.setBlockBounds(0.1F, 0.3F, 0.8F, 0.2F, 0.9F, 0.9F); var4.renderStandardBlock(var0, var1, var2, var3); var4.overrideBlockTexture = Blocks.glowstone.getBlockTextureFromSide(0); var0.setBlockBounds(0.2F, 0.3F, 0.2F, 0.8F, 0.9F, 0.8F); var4.renderStandardBlock(var0, var1, var2, var3); var4.overrideBlockTexture = null; return true; } } By the way the two block changing look thing only happens when I comment that out so I am completely lost.
  9. Hello I am having a problem with rendering the block in the world as the title suggests. What is going on is that only the final renderStandardBlock is being called. public static boolean renderBottom(Block var0, int var1, int var2, int var3, RenderBlocks var4) { var4.overrideBlockTexture = texture; var0.setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 0.1F, 0.8F); var4.renderStandardBlock(var0, var1, var2, var3); var4.overrideBlockTexture = texture; var0.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F); var4.renderStandardBlock(var0, var1, var2, var3); var4.overrideBlockTexture = null; return true; } So for the method above only this will be called and everything above it is just lost. var4.overrideBlockTexture = texture; var0.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F); var4.renderStandardBlock(var0, var1, var2, var3); The Renderer is working but only the final parts. package grim3212.mc.lampposts; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.init.Blocks; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderingHandler implements ISimpleBlockRenderingHandler { @Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { return modelId == LampPosts.renderID ? this.renderLampPost(block, x, y, z, renderer) : false; } @Override public boolean shouldRender3DInInventory(int modelId) { return false; } @Override public int getRenderId() { return LampPosts.renderID; } public boolean renderLampPost(Block var1, int var2, int var3, int var4, RenderBlocks var5) { World var7 = FMLClientHandler.instance().getWorldClient(); int var8 = var7.getBlockMetadata(var2, var3, var4); if (var8 == 0) { RenderLampPost.setTexture(Blocks.iron_block.getBlockTextureFromSide(0)); return RenderLampPost.renderBottom(var1, var2, var3, var4, var5); } else if (var8 == 1) { RenderLampPost.setTexture(Blocks.iron_block.getBlockTextureFromSide(0)); return RenderLampPost.renderMiddle(var1, var2, var3, var4, var5); } else if (var8 == 2) { RenderLampPost.setTexture(Blocks.iron_block.getBlockTextureFromSide(0)); return RenderLampPost.renderTop(var1, var2, var3, var4, var5); } else if (var8 == 3) { RenderLampPost.setTexture(Blocks.nether_brick.getBlockTextureFromSide(0)); return RenderLampPost.renderBottom(var1, var2, var3, var4, var5); } else if (var8 == 4) { RenderLampPost.setTexture(Blocks.nether_brick.getBlockTextureFromSide(0)); return RenderLampPost.renderMiddle(var1, var2, var3, var4, var5); } else if (var8 == 5) { RenderLampPost.setTexture(Blocks.nether_brick.getBlockTextureFromSide(0)); return RenderLampPost.renderTop(var1, var2, var3, var4, var5); } else { return false; } } } Also just in case I am using Forge 10.12.0.134 Any help is appreciated. Thanks EDIT: Workaround: Instead of using this method I used Techne models instead.
  10. Hello, I am having a problem while rendering my block in the inventory. It is working fine in Eclipse while developing but once I build and move it to try it outside of eclipse it has a moving texture that it goes through. The in world rendering works fine in both environments but just the items in the inventory are having problems. When it should look like this. I have no idea where this orange texture is coming from and it is also cycling through a bunch of different orange and reddish colors. RenderChimney package grim3212.mc.fireplaces; import java.awt.Color; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.MinecraftForgeClient; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderChimney implements ISimpleBlockRenderingHandler { private int MaterialIndex = 0; private boolean IsLit = false; private TileEntityFireplaceBase tileentity; private Color color; private float red; private float green; private float blue; public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { renderer.overrideBlockBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); FireplaceCoreClient.renderBlockInventory(block, renderer, metadata); renderer.overrideBlockTexture = FireplaceCoreClient.Tex_chimney18; renderer.overrideBlockBounds(0.05D, -0.01D, 0.05D, 0.95D, 1.01D, 0.95D); FireplaceCoreClient.renderBlockInventory(block, renderer, metadata); renderer.unlockBlockBounds(); renderer.clearOverrideBlockTexture(); } public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { this.tileentity = ((TileEntityFireplaceBase) world.getTileEntity(x, y, z)); this.MaterialIndex = this.tileentity.GetMaterialIndex(); this.IsLit = this.tileentity.GetIsLit(); renderer.overrideBlockBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); renderer.renderStandardBlock(block, x, y, z); this.color = Color.BLACK; this.red = this.color.getRed(); this.green = this.color.getGreen(); this.blue = this.color.getBlue(); if (FireplaceCore.SettingUseNewTopTexture) { boolean left = (world.getBlock(x - 1, y, z) == FireplaceCore.BlockChimney) && (checkUncovered(world, x - 1, y + 1, z)); boolean corner1 = world.getBlock(x - 1, y, z + 1) == FireplaceCore.BlockChimney; boolean corner2 = world.getBlock(x - 1, y, z - 1) == FireplaceCore.BlockChimney; boolean right = (world.getBlock(x + 1, y, z) == FireplaceCore.BlockChimney) && (checkUncovered(world, x + 1, y + 1, z)); boolean corner3 = world.getBlock(x + 1, y, z + 1) == FireplaceCore.BlockChimney; boolean corner4 = world.getBlock(x + 1, y, z - 1) == FireplaceCore.BlockChimney; boolean up = (world.getBlock(x, y, z - 1) == FireplaceCore.BlockChimney) && (checkUncovered(world, x, y + 1, z - 1)); boolean down = (world.getBlock(x, y, z + 1) == FireplaceCore.BlockChimney) && (checkUncovered(world, x, y + 1, z + 1)); double height = -0.01D; for (int i = 0; i < 2; i++) { renderer.overrideBlockTexture = (renderer.overrideBlockTexture = FireplaceCoreClient.Tex_chimney2); renderer.overrideBlockBounds(0.1875D, height, 0.1875D, 0.8125D, height, 0.8125D); renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, this.red / 255.0F, this.green / 255.0F, this.blue / 255.0F); if (left) { renderer.overrideBlockTexture = FireplaceCoreClient.Tex_chimney7; renderer.overrideBlockBounds(0.0D, height, 0.1875D, 0.1875D, height, 0.8125D); renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, this.red / 255.0F, this.green / 255.0F, this.blue / 255.0F); } if (right) { renderer.overrideBlockTexture = FireplaceCoreClient.Tex_chimney8; renderer.overrideBlockBounds(0.8125D, height, 0.1875D, 1.0D, height, 0.8125D); renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, this.red / 255.0F, this.green / 255.0F, this.blue / 255.0F); } if (up) { renderer.overrideBlockTexture = FireplaceCoreClient.Tex_chimney9; renderer.overrideBlockBounds(0.1875D, height, 0.0D, 0.8125D, height, 0.1875D); renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, this.red / 255.0F, this.green / 255.0F, this.blue / 255.0F); } if (down) { renderer.overrideBlockTexture = FireplaceCoreClient.Tex_chimney10; renderer.overrideBlockBounds(0.1875D, height, 0.8125D, 0.8125D, height, 1.0D); renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, this.red / 255.0F, this.green / 255.0F, this.blue / 255.0F); } if ((corner2) && (up) && (left)) { renderer.overrideBlockTexture = FireplaceCoreClient.Tex_chimney3; renderer.overrideBlockBounds(0.0D, height, 0.0D, 0.1875D, height, 0.1875D); renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, this.red / 255.0F, this.green / 255.0F, this.blue / 255.0F); } if ((corner4) && (up) && (right)) { renderer.overrideBlockTexture = FireplaceCoreClient.Tex_chimney4; renderer.overrideBlockBounds(0.8125D, height, 0.0D, 1.0D, height, 0.1875D); renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, this.red / 255.0F, this.green / 255.0F, this.blue / 255.0F); } if ((corner1) && (down) && (left)) { renderer.overrideBlockTexture = FireplaceCoreClient.Tex_chimney5; renderer.overrideBlockBounds(0.0D, height, 0.8125D, 0.1875D, height, 1.0D); renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, this.red / 255.0F, this.green / 255.0F, this.blue / 255.0F); } if ((corner3) && (down) && (right)) { renderer.overrideBlockTexture = FireplaceCoreClient.Tex_chimney6; renderer.overrideBlockBounds(0.8125D, height, 0.8125D, 1.0D, height, 1.0D); renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, this.red / 255.0F, this.green / 255.0F, this.blue / 255.0F); } height += 1.02D; } } else { renderer.overrideBlockTexture = FireplaceCoreClient.Tex_chimney18; renderer.overrideBlockBounds(0.05D, -0.01D, 0.05D, 0.95D, 1.01D, 0.95D); renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, this.red / 255.0F, this.green / 255.0F, this.blue / 255.0F); } renderer.unlockBlockBounds(); renderer.clearOverrideBlockTexture(); return true; } private boolean checkUncovered(IBlockAccess world, int x, int y, int z) { return (!world.getBlock(x, y, z).isOpaqueCube()) && (world.getBlock(x, y, z) != FireplaceCore.BlockChimney); } public boolean shouldRender3DInInventory(int modelId) { return true; } public int getRenderId() { return FireplaceCore.RenderIDChimney; } } Method - renderBlockInventory @SideOnly(Side.CLIENT) public static void renderBlockInventory(Block block, RenderBlocks renderer, int metadata) { Tessellator tessellator = Tessellator.instance; if (tessellator.renderingWorldRenderer) tessellator.draw(); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, -1.0F, 0.0F); renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, -1.0F); renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, 1.0F); renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(-1.0F, 0.0F, 0.0F); renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 0.0F, 0.0F); renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, metadata)); tessellator.draw(); GL11.glTranslatef(0.5F, 0.5F, 0.5F); } Thanks for any help! EDIT: I ended up finding the problem... It was because the registerBlockIcons method was not being called while in the inventory because of an if statement I had in it. Works properly now.
  11. Well each Block itself should start out with 18 inventory slots. Then you place them on top of each other and it adds 18 more in the form of 2 rows. Well right now the TileEntity for this Block extends a TileEntity that all of my Blocks extend and I am fairly certain that everything is correct since the other Blocks are working. The only real things in this Blocks TileEntity class are but, I will keep looking around trying to find the culprit. public int getSizeInventory() { return 18; } public int getLowestMetadata() { int ymod = 0; while (this.worldObj.getBlock(this.xCoord, this.yCoord - ymod - 1, this.zCoord) == this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord)) ymod++; return this.worldObj.getBlockMetadata(this.xCoord, this.yCoord - ymod, this.zCoord); } package grim3212.mc.morestorage; import grim3212.mc.core.packet.PacketPipeline; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class TileEntityStorage extends TileEntity implements IInventory { private String customName; private int numUsingPlayers = 0; public int rotation = 0; private boolean direction = false; private ItemStack[] contents; private int storagePassword = -1; public boolean hasInitialData = false; private int hasInitialDataTimeout = 0; public TileEntityStorage() { this.contents = new ItemStack[getSizeInventory()]; } public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); this.storagePassword = nbttagcompound.getInteger("StoragePassword"); NBTTagList nbttaglist = nbttagcompound.getTagList("Items", 10); this.contents = new ItemStack[getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.getCompoundTagAt(i); int j = nbttagcompound1.getByte("Slot") & 0xFF; if ((j >= 0) && (j < this.contents.length)) { this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } } public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); nbttagcompound.setInteger("StoragePassword", this.storagePassword); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.contents.length; i++) { if (this.contents[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); this.contents[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } nbttagcompound.setTag("Items", nbttaglist); } @SideOnly(Side.CLIENT) public boolean receiveClientEvent(int eventID, int eventInput) { if (eventID == 1) { this.numUsingPlayers = eventInput; return true; } if (eventID == 2) { this.storagePassword = eventInput; return true; } return super.receiveClientEvent(eventID, eventInput); } public void sendStoragePassword() { PacketPipeline.sendToServer(new MoreStoragePacket(xCoord, yCoord, zCoord, storagePassword, 2)); } public void setStoragePassword(int password) { this.storagePassword = password; if (FMLCommonHandler.instance().getEffectiveSide() != Side.CLIENT) sendStoragePassword(); } public void clearStoragePassword() { this.storagePassword = -1; if (FMLCommonHandler.instance().getEffectiveSide() != Side.CLIENT) sendStoragePassword(); } public boolean hasPassword() { return this.storagePassword > 0; } public int getPassword() { return this.storagePassword; } public void updateEntity() { if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { if ((!this.hasInitialData) && (this.hasInitialDataTimeout <= 0)) { PacketPipeline.sendToServer(new MoreStoragePacket(xCoord, yCoord, zCoord, 1)); this.hasInitialDataTimeout = 10; } if (this.hasInitialDataTimeout > 0) this.hasInitialDataTimeout -= 1; } boolean prevdirection = this.direction; this.direction = (this.numUsingPlayers > 0); if ((!prevdirection) && (this.direction)) this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, getOpenSound(), 1.0F, 1.0F); int prevrotation = this.rotation; int addspeed = (int) (Math.abs(90 - this.rotation) / 10.0F); if (this.direction) { if (this.rotation < 90) { this.rotation += 6 + addspeed; } } else if (this.rotation > 0) { this.rotation -= 6 + addspeed; } if (this.rotation < 0) this.rotation = 0; if (this.rotation > 90) this.rotation = 90; if ((prevrotation > this.rotation) && (this.rotation == 0)) { this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, getCloseSound(), 1.0F, 1.0F); } } protected String getOpenSound() { return "random.door_open"; } protected String getCloseSound() { return "random.door_close"; } public void openInventory() { this.numUsingPlayers += 1; if (this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord) != Blocks.air) this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord), 1, this.numUsingPlayers); } public void closeInventory() { this.numUsingPlayers -= 1; if (this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord) != Blocks.air) this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord), 1, this.numUsingPlayers); } public void invalidate() { super.invalidate(); } public String getInventoryName() { return this.customName != null ? this.customName : getSubInvName(); } public String getSubInvName() { return "NoName"; } public boolean hasCustomInventoryName() { return false; } public int getSizeInventory() { return 27; } public ItemStack decrStackSize(int i, int j) { if ((hasPassword()) && (this.numUsingPlayers == 0)) return null; if (this.contents[i] != null) { if (this.contents[i].stackSize <= j) { ItemStack itemstack = this.contents[i]; this.contents[i] = null; markDirty(); return itemstack; } ItemStack itemstack = this.contents[i].splitStack(j); if (this.contents[i].stackSize == 0) { this.contents[i] = null; } markDirty(); return itemstack; } return null; } public ItemStack getStackInSlot(int i) { if ((hasPassword()) && (this.numUsingPlayers == 0)) return null; return this.contents[i]; } public ItemStack getStackInSlotOnClosing(int i) { return null; } public ItemStack getStackInSlotNoLockBlock(int i) { return this.contents[i]; } public int getInventoryStackLimit() { return 64; } public void setInventorySlotContents(int i, ItemStack itemstack) { this.contents[i] = itemstack; if ((itemstack != null) && (itemstack.stackSize > getInventoryStackLimit())) { itemstack.stackSize = getInventoryStackLimit(); } markDirty(); } public boolean isUseableByPlayer(EntityPlayer entityplayer) { if ((FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) && (!this.hasInitialData)) return false; return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) == this; } public boolean isItemValidForSlot(int i, ItemStack itemstack) { return !hasPassword(); } }
  12. Alright thanks for the reply, so I ended up doing as you said and it is strange because the list of inventory items it is about to send is 54 unless I am misreading this.
  13. OK so I am having a problem when opening the GUI on one of my blocks. It instantly crashes and displays this every time and I am unsure of what the problem is because I only changed a few method names to update to 1.7.2. I have checked around and have seen this same error on here and the only one that was solved was by changing the code in the GUIHandler when mine is correct so I am completely lost and have been trying to figure this out for awhile now. But I am pretty sure that it has to do with either the Container or Inventory class. If you need anything else I'll be sure to post it ASAP... Thanks for any help. [05:36:34] [Client thread/FATAL]: Unreported exception thrown! java.lang.IndexOutOfBoundsException: Index: 45, Size: 45 at java.util.ArrayList.rangeCheck(ArrayList.java:635) ~[?:1.7.0_45] at java.util.ArrayList.get(ArrayList.java:411) ~[?:1.7.0_45] at net.minecraft.inventory.Container.getSlot(Container.java:136) ~[Container.class:?] at net.minecraft.inventory.Container.putStacksInSlots(Container.java:564) ~[Container.class:?] at net.minecraft.client.network.NetHandlerPlayClient.handleWindowItems(NetHandlerPlayClient.java:1194) ~[NetHandlerPlayClient.class:?] at net.minecraft.network.play.server.S30PacketWindowItems.processPacket(S30PacketWindowItems.java:70) ~[s30PacketWindowItems.class:?] at net.minecraft.network.play.server.S30PacketWindowItems.processPacket(S30PacketWindowItems.java:78) ~[s30PacketWindowItems.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:242) ~[NetworkManager.class:?] at net.minecraft.client.multiplayer.PlayerControllerMP.updateController(PlayerControllerMP.java:339) ~[PlayerControllerMP.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1689) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1036) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:951) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:112) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_45] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_45] at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?] Inventory Class package grim3212.mc.morestorage.Tower; import java.util.ArrayList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; public class InventoryItemTower implements IInventory { public ArrayList<TileEntityItemTower> itemTowers = new ArrayList(); public TileEntityItemTower mainTower; public InventoryItemTower(ArrayList<TileEntityItemTower> itemTowers, TileEntityItemTower mainTower) { this.itemTowers = itemTowers; this.mainTower = mainTower; } public int getSizeInventory() { return this.mainTower.getSizeInventory() * this.itemTowers.size(); } public ItemStack getStackInSlot(int i) { return getInvFromSlot(i).getStackInSlot(getLocalSlot(i)); } public ItemStack decrStackSize(int i, int j) { return getInvFromSlot(i).decrStackSize(getLocalSlot(i), j); } public ItemStack getStackInSlotOnClosing(int i) { return getInvFromSlot(i).getStackInSlotOnClosing(getLocalSlot(i)); } public void setInventorySlotContents(int i, ItemStack itemstack) { getInvFromSlot(i).setInventorySlotContents(getLocalSlot(i), itemstack); } public String getInventoryName() { return this.mainTower.getInventoryName(); } public boolean hasCustomInventoryName() { return this.mainTower.hasCustomInventoryName(); } public int getInventoryStackLimit() { return this.mainTower.getInventoryStackLimit(); } public void markDirty() { for (IInventory inventory : this.itemTowers) inventory.markDirty(); } public boolean isUseableByPlayer(EntityPlayer entityplayer) { boolean flag = true; for (IInventory inventory : this.itemTowers) { if (!inventory.isUseableByPlayer(entityplayer)) flag = false; } return flag; } public void openInventory() { for (IInventory inventory : this.itemTowers) inventory.openInventory(); } public void closeInventory() { for (IInventory inventory : this.itemTowers) inventory.closeInventory(); } public void setAnimation(int animID) { for (TileEntityItemTower inventory : this.itemTowers) inventory.setAnimation(animID); } private int getLocalSlot(int slot) { return slot % this.mainTower.getSizeInventory(); } private IInventory getInvFromSlot(int slot) { int inventoryIndex = (int) Math.floor(slot / this.mainTower.getSizeInventory()); return (IInventory) this.itemTowers.get(inventoryIndex); } public boolean isItemValidForSlot(int i, ItemStack itemstack) { return getInvFromSlot(i).isItemValidForSlot(getLocalSlot(i), itemstack); } } Container Class package grim3212.mc.morestorage.Tower; import grim3212.mc.morestorage.SlotMoveable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class ContainerItemTower extends Container { private IInventory itemTowers; private int numRows; public ContainerItemTower(IInventory playerInventory, IInventory itemTowers) { this.itemTowers = itemTowers; this.numRows = (itemTowers.getSizeInventory() / 9); itemTowers.openInventory(); for (int j = 0; j < this.numRows; j++) { for (int k = 0; k < 9; k++) { addSlotToContainer(new SlotMoveable(itemTowers, k + j * 9, 8 + k * 18, 18 + j * 18)); } } // Player Inventory for (int j = 0; j < 3; j++) { for (int k = 0; k < 9; k++) { addSlotToContainer(new Slot(playerInventory, k + j * 9 + 9, 8 + k * 18, 50 + j * 18)); } } // Player Hotbar Inventory for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(playerInventory, j, 8 + j * 18, 108)); } if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) setDisplayRow(0); } @SideOnly(Side.CLIENT) public void setDisplayRow(int row) { int minSlot = row * 9; int maxSlot = (row + 1) * 9; for (int slotIndex = 0; slotIndex < this.numRows * 9; slotIndex++) { if ((slotIndex >= minSlot) && (slotIndex < maxSlot)) { int modRow = (int) Math.floor((slotIndex - minSlot) / 9.0D); int modColumn = slotIndex % 9; ((SlotMoveable) this.inventorySlots.get(slotIndex)).setSlotPosition(8 + modColumn * 18, 18 + modRow * 18); } else { ((SlotMoveable) this.inventorySlots.get(slotIndex)).setSlotPosition(-9999, -9999); } } } public boolean canInteractWith(EntityPlayer par1EntityPlayer) { return this.itemTowers.isUseableByPlayer(par1EntityPlayer); } public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slotID) { ItemStack itemstack = null; Slot slot = (Slot) this.inventorySlots.get(slotID); if ((slot != null) && (slot.getHasStack())) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (slotID < this.numRows * 9) { if (!mergeItemStack(itemstack1, this.numRows * 9, this.inventorySlots.size(), true)) { return null; } } else if (!mergeItemStack(itemstack1, 0, this.numRows * 9, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack) null); } else { slot.onSlotChanged(); } } return itemstack; } public void onContainerClosed(EntityPlayer par1EntityPlayer) { super.onContainerClosed(par1EntityPlayer); this.itemTowers.closeInventory(); } } Block package grim3212.mc.morestorage.Tower; import grim3212.mc.morestorage.BlockMoreStorage; import grim3212.mc.morestorage.MoreStorageCore; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; public class BlockItemTower extends BlockMoreStorage { public BlockItemTower(Material material) { super(material); } public TileEntity createNewTileEntity(World world, int metadata) { return new TileEntityItemTower(); } public boolean hasRotatedDoor() { return true; } public boolean isDoorBlocked(World world, int i, int j, int k) { return false; } public void onBlockClicked(World world, int i, int j, int k, EntityPlayer entityplayer) { } public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { TileEntity tileentity = world.getTileEntity(i, j, k); if ((tileentity == null) || (entityplayer.isSneaking())) return false; entityplayer.openGui(MoreStorageCore.instance, 4, world, i, j, k); return true; } } And GUI Handler just in case public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileentity = world.getTileEntity(x, y, z); TileEntity tileentitytop = world.getTileEntity(x, y + 1, z); switch (ID) { // Removed the other cases since they are unneeded. case 4: return getItemTowerContainer(player, world, x, y, z); } return null; } public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileentity = world.getTileEntity(x, y, z); TileEntity tileentitytop = world.getTileEntity(x, y + 1, z); switch (ID) { // Removed the other cases since they are unneeded. case 4: return getItemTowerGui(player, world, x, y, z); } return null; } private Object getItemTowerGui(EntityPlayer player, World world, int x, int y, int z) { TileEntity tileentity = world.getTileEntity(x, y, z); if (checkUsable(tileentity, player)) { int ymod = y; while (world.getBlock(x, ymod - 1, z) == world.getBlock(x, y, z)) ymod--; ArrayList itemTowers = new ArrayList(); while (world.getBlock(x, ymod, z) == world.getBlock(x, y, z)) { itemTowers.add((TileEntityItemTower) world.getTileEntity(x, ymod, z)); ymod++; } InventoryItemTower towerInv = new InventoryItemTower(itemTowers, (TileEntityItemTower) tileentity); return new GuiItemTower(player.inventory, towerInv); } return null; } private Object getItemTowerContainer(EntityPlayer player, World world, int x, int y, int z) { TileEntity tileentity = world.getTileEntity(x, y, z); if (checkUsable(tileentity, player)) { int ymod = y; while (world.getBlock(x, ymod - 1, z) == world.getBlock(x, y, z)) ymod--; ArrayList itemTowers = new ArrayList(); while (world.getBlock(x, ymod, z) == world.getBlock(x, y, z)) { itemTowers.add((TileEntityItemTower) world.getTileEntity(x, ymod, z)); ymod++; } InventoryItemTower towerInv = new InventoryItemTower(itemTowers, (TileEntityItemTower) tileentity); return new ContainerItemTower(player.inventory, towerInv); } return null; }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.