Blue_Atlas
Members-
Posts
132 -
Joined
-
Last visited
Everything posted by Blue_Atlas
-
I don't know exactly what you need to do but I think it needs to be something along the lines of Blocks.WOOL.getDefaultState().withProperty(); Thing is I have not messed with wool so I don't know what properties it has or what you need to put inside the withProperty() part
-
I'm using this method to set the sky color in my biome class and I'm trying to make it a dark green, does anyone know of a value that does that? @SideOnly(Side.CLIENT) public int getSkyColorByTemp(float currentTemperature) { return 0; }
-
I'm still trying to figure this out if anyone could help
-
I'm following this tutorial for creating a dimension but I don't know how to make biomesForGeneration my own list of biomes. Here is my code: public class FelChunkGenerator implements IChunkGenerator { private final World worldObj; private Random random; private Biome[] biomesForGeneration; private List<Biome.SpawnListEntry> mobs = Lists.newArrayList(new Biome.SpawnListEntry(EntityZombie.class, 100, 2, 2)); private MapGenBase caveGenerator = new MapGenCaves(); private NormalTerrainGenerator terraingen = new NormalTerrainGenerator(); public FelChunkGenerator(World worldObj) { this.worldObj = worldObj; long seed = worldObj.getSeed(); this.random = new Random((seed + 516) * 314); terraingen.setup(worldObj, random); caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, InitMapGenEvent.EventType.CAVE); } @Override public Chunk generateChunk(int x, int z) { ChunkPrimer chunkprimer = new ChunkPrimer(); // Setup biomes for terraingen this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomesForGeneration(this.biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10); terraingen.setBiomesForGeneration(biomesForGeneration); terraingen.generate(x, z, chunkprimer); // Setup biomes again for actual biome decoration this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomes(this.biomesForGeneration, x * 16, z * 16, 16, 16); // This will replace stone with the biome specific stones terraingen.replaceBiomeBlocks(x, z, chunkprimer, this, biomesForGeneration); // Generate caves this.caveGenerator.generate(this.worldObj, x, z, chunkprimer); Chunk chunk = new Chunk(this.worldObj, chunkprimer, x, z); byte[] biomeArray = chunk.getBiomeArray(); for (int i = 0; i < biomeArray.length; ++i) { biomeArray[i] = (byte)Biome.getIdForBiome(this.biomesForGeneration[i]); } chunk.generateSkylightMap(); return chunk; } @Override public void populate(int x, int z) { int i = x * 16; int j = z * 16; BlockPos blockpos = new BlockPos(i, 0, j); Biome biome = this.worldObj.getBiome(blockpos.add(16, 0, 16)); // Add biome decorations (like flowers, grass, trees, ...) biome.decorate(this.worldObj, this.random, blockpos); // Make sure animals appropriate to the biome spawn here when the chunk is generated WorldEntitySpawner.performWorldGenSpawning(this.worldObj, biome, i + 8, j + 8, 16, 16, this.random); } @Override public boolean generateStructures(Chunk chunkIn, int x, int z) { return false; } @Override public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) { // If you want normal creatures appropriate for this biome then uncomment the // following two lines: // Biome biome = this.worldObj.getBiome(pos); // return biome.getSpawnableList(creatureType); if (creatureType == EnumCreatureType.MONSTER){ return mobs; } return ImmutableList.of(); } @Nullable @Override public BlockPos getNearestStructurePos(World worldIn, String structureName, BlockPos position, boolean findUnexplored) { return null; } @Override public boolean isInsideStructure(World worldIn, String structureName, BlockPos pos) { return false; } @Override public void recreateStructures(Chunk chunkIn, int x, int z) { } } can anyone help me?
-
I think in a previous version of forge it was assigned somewhere in TerrainGen as InitMapGenEvent.EventType.CAVE but got changed. however I managed to find that so I'm all good now
-
I'm running on the newest recommended version of forge and this line of code has an error that CAVE cannot be resolved to a variable caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE); I think it is something that does not exist in that code anymore but I don't know what I need to change it to to get the error to go away
-
I already saw that but it looks like it would create something like the aether dimension from how it talks about what you are going to do in the tutorial
-
could anyone point me in the direction of a good tutorial for creating a multi biome overworld style dimension?
-
sorry really should have looked at code before posting here, thanks for the help!
-
BlockBase: package com.atlas.thelostportal.objects.blocks; import com.atlas.thelostportal.objects.init.ModBlocksInit; import com.atlas.thelostportal.objects.init.ModItemsInit; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemBlock; public class BlockBase extends Block { public BlockBase(String name, Material material, CreativeTabs tab, float hardness, float resistence, String tool, int harvestLevel) { super(material); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(tab); setHardness(hardness); setResistance(resistence); setHarvestLevel(tool, harvestLevel); ModBlocksInit.BLOCKS.add(this); ModItemsInit.ITEMS.add(new ItemBlock(this).setRegistryName(name)); } }
-
this block: public static final Block CHORUS_STONE = new BlockBase("chorus_stone", Material.ROCK, Main.lostportaltab, 2.5F, 45.0F, "pickaxe", 1); does not explode when i detonate tnt next to it yet endstone does
-
I have some values for my blocks blast resistances but vanilla blocks that apparently have the same values explode when my blocks don't. are the actual values different from those on the wiki for vanilla blocks?
-
I have a few recipes and none of them are working here is one of them { "type": "minecraft:crafting_shaped", "pattern": [ "SSS", "SFS", "SCS" ], "key": { "S": { "item": "minecraft:stone" }, "C": { "item": "thelostportal:catalyst" }, "F": { "item": "minecraft:furnace" } }, "result": { "item": "thelostportal:non_energy_forge", "count": 1 } } I think I wrote the recipe right but it isn't working. Is there something I forgot to do?
-
(figured out)nether portal portal block rotation
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
nvm looked and found .withRotation(Rotation.CLOCKWISE_90) function -
I am currently messing with having a block place the portal block from the nether portal and am trying to change which axis it is on here is my current code for setting a block to portal world.setBlockState(pos.up(), Blocks.PORTAL.getDefaultState().withProperty(BlockPortal.AXIS, value)); what value do I need for value to make it face along the x and z axis?
-
wait nvm think I figured out how I am going to do this
-
alright, I figured out how to make my block work and decided to transfer it over to needing fuel unless a certain block is in a location near it but it does not update to the burning state texture when burning using block. Where do I need to change it to make it change the texture?
-
im in 1.12.2
-
that does not make sense
-
I haven't updated the code since what I had in my first post besides registering the TE now, the return this.burnTime > 0; returns true if the burnTime is greater than 0, and I still have the fuel code in there because I am trying to make the block function with a block formation around it before removing the fuel so I can make sure it works well
-
also it does not drop items in its inventory when broken
-
alright, that fixed the bugs I had but now it just consumes the items, returns nothing, and the progress bar doesn't move
-
I've got a tile entity I have made but every time I try to use it it crashes the game, also when broken it seems to leave behind the tile entity part. here is my crash report: ---- Minecraft Crash Report ---- // Hi. I'm Minecraft, and I'm a crashaholic. Time: 3/11/19 11:05 AM Description: Ticking block entity java.lang.RuntimeException: class com.atlas.thelostportal.objects.blocks.tileentity.TileEntityNonEnergyForge is missing a mapping! This is a bug! at net.minecraft.tileentity.TileEntity.writeInternal(TileEntity.java:89) at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:80) at com.atlas.thelostportal.objects.blocks.tileentity.TileEntityNonEnergyForge.writeToNBT(TileEntityNonEnergyForge.java:89) at net.minecraftforge.common.util.BlockSnapshot.getTileNBT(BlockSnapshot.java:132) at net.minecraftforge.common.util.BlockSnapshot.<init>(BlockSnapshot.java:61) at net.minecraftforge.common.util.BlockSnapshot.<init>(BlockSnapshot.java:82) at net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(BlockSnapshot.java:113) at net.minecraft.world.World.setBlockState(World.java:394) at com.atlas.thelostportal.objects.blocks.BlockNonEnergyForge.setState(BlockNonEnergyForge.java:90) at com.atlas.thelostportal.objects.blocks.tileentity.TileEntityNonEnergyForge.update(TileEntityNonEnergyForge.java:130) at net.minecraft.world.World.updateEntities(World.java:2007) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:643) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:842) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) at java.lang.Thread.run(Thread.java:748) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Server thread Stacktrace: at net.minecraft.tileentity.TileEntity.writeInternal(TileEntity.java:89) at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:80) at com.atlas.thelostportal.objects.blocks.tileentity.TileEntityNonEnergyForge.writeToNBT(TileEntityNonEnergyForge.java:89) at net.minecraftforge.common.util.BlockSnapshot.getTileNBT(BlockSnapshot.java:132) at net.minecraftforge.common.util.BlockSnapshot.<init>(BlockSnapshot.java:61) at net.minecraftforge.common.util.BlockSnapshot.<init>(BlockSnapshot.java:82) at net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(BlockSnapshot.java:113) at net.minecraft.world.World.setBlockState(World.java:394) at com.atlas.thelostportal.objects.blocks.BlockNonEnergyForge.setState(BlockNonEnergyForge.java:90) at com.atlas.thelostportal.objects.blocks.tileentity.TileEntityNonEnergyForge.update(TileEntityNonEnergyForge.java:130) -- Block entity being ticked -- Details: Name: null // com.atlas.thelostportal.objects.blocks.tileentity.TileEntityNonEnergyForge Block type: ID #257 (tile.non_energy_forge // com.atlas.thelostportal.objects.blocks.BlockNonEnergyForge // thelostportal:non_energy_forge) Block data value: 3 / 0x3 / 0b0011 Block location: World: (2,5,9), Chunk: (at 2,0,9 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Actual block type: ID #257 (tile.non_energy_forge // com.atlas.thelostportal.objects.blocks.BlockNonEnergyForge // thelostportal:non_energy_forge) Actual block data value: 3 / 0x3 / 0b0011 Stacktrace: at net.minecraft.world.World.updateEntities(World.java:2007) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:643) -- Affected level -- Details: Level name: New World All players: 1 total; [EntityPlayerMP['Player57'/0, l='New World', x=1.77, y=5.00, z=10.74]] Chunk stats: ServerChunkCache: 625 Drop: 0 Level seed: 2011117741212307537 Level generator: ID 01 - flat, ver 0. Features enabled: true Level generator options: 3;minecraft:air;127;decoration Level spawn location: World: (8,4,8), Chunk: (at 8,0,8 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Level time: 101654 game time, 5182 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 8773 (now: true), thunder time: 89549 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:842) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) at java.lang.Thread.run(Thread.java:748) -- System Details -- Details: Minecraft Version: 1.12.2 Operating System: Mac OS X (x86_64) version 10.13.6 Java Version: 1.8.0_191, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 397558888 bytes (379 MB) / 756547584 bytes (721 MB) up to 1908932608 bytes (1820 MB) JVM Flags: 0 total; IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.42 Powered by Forge 14.23.5.2768 5 mods loaded, 5 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored | State | ID | Version | Source | Signature | |:--------- |:------------- |:------------ |:-------------------------------- |:--------- | | UCHIJAAAA | minecraft | 1.12.2 | minecraft.jar | None | | UCHIJAAAA | mcp | 9.42 | minecraft.jar | None | | UCHIJAAAA | FML | 8.0.99.99 | forgeSrc-1.12.2-14.23.5.2768.jar | None | | UCHIJAAAA | forge | 14.23.5.2768 | forgeSrc-1.12.2-14.23.5.2768.jar | None | | UCHIJAAAA | thelostportal | 1.0 | bin | None | Loaded coremods (and transformers): GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Player Count: 1 / 8; [EntityPlayerMP['Player57'/0, l='New World', x=1.77, y=5.00, z=10.74]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' and here is my code TE: package com.atlas.thelostportal.objects.blocks.tileentity; import com.atlas.thelostportal.objects.blocks.BlockNonEnergyForge; import com.atlas.thelostportal.objects.blocks.recipes.NonEnergyForgeRecipes; import com.atlas.thelostportal.objects.init.ModBlocksInit; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.item.ItemTool; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; public class TileEntityNonEnergyForge extends TileEntity implements ITickable { private ItemStackHandler handler = new ItemStackHandler(4); private String customName; private ItemStack smelting = ItemStack.EMPTY; private int burnTime; private int currentBurnTime; private int cookTime; private int totalCookTime = 200; @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return true; else return false; } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return (T) this.handler; return super.getCapability(capability, facing); } public boolean hasCustomName() { return this.customName != null && !this.customName.isEmpty(); } public void setCustomName(String customName) { this.customName = customName; } @Override public ITextComponent getDisplayName() { return this.hasCustomName() ? new TextComponentString(this.customName) : new TextComponentTranslation("container.non_energy_forge"); } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.handler.deserializeNBT(compound.getCompoundTag("Inventory")); this.burnTime = compound.getInteger("BurnTime"); this.cookTime = compound.getInteger("CookTime"); this.totalCookTime = compound.getInteger("CookTimeTotal"); this.currentBurnTime = getItemBurnTime((ItemStack)this.handler.getStackInSlot(2)); if(compound.hasKey("CustomName", 8)) this.setCustomName(compound.getString("CustomName")); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("BurnTime", (short)this.burnTime); compound.setInteger("CookTime", (short)this.cookTime); compound.setInteger("CookTimeTotal", (short)this.totalCookTime); compound.setTag("Inventory", this.handler.serializeNBT()); if(this.hasCustomName()) compound.setString("CustomName", this.customName); return compound; } public boolean isBurning() { if(world.getBlockState(pos.down()).getBlock() == ModBlocksInit.CHORUS_STONE && world.getBlockState(pos.down().north()).getBlock() == ModBlocksInit.CHORUS_STONE && world.getBlockState(pos.down().north().east()).getBlock() == ModBlocksInit.CHORUS_STONE && world.getBlockState(pos.down().east()).getBlock() == ModBlocksInit.CHORUS_STONE && world.getBlockState(pos.down().east().south()).getBlock() == ModBlocksInit.CHORUS_STONE && world.getBlockState(pos.down().south()).getBlock() == ModBlocksInit.CHORUS_STONE && world.getBlockState(pos.down().south().west()).getBlock() == ModBlocksInit.CHORUS_STONE && world.getBlockState(pos.down().west()).getBlock() == ModBlocksInit.CHORUS_STONE && world.getBlockState(pos.down().west().north()).getBlock() == ModBlocksInit.CHORUS_STONE) { return this.burnTime > 0; } else { return false; } } @SideOnly(Side.CLIENT) public static boolean isBurning(TileEntityNonEnergyForge te) { return te.getField(0) > 0; } public void update() { if(this.isBurning()) { --this.burnTime; BlockNonEnergyForge.setState(true, world, pos); } ItemStack[] inputs = new ItemStack[] {handler.getStackInSlot(0), handler.getStackInSlot(1)}; ItemStack fuel = this.handler.getStackInSlot(2); if(this.isBurning() || !fuel.isEmpty() && !this.handler.getStackInSlot(0).isEmpty() || this.handler.getStackInSlot(1).isEmpty()) { if(!this.isBurning() && this.canSmelt()) { this.burnTime = getItemBurnTime(fuel); this.currentBurnTime = burnTime; if(this.isBurning() && !fuel.isEmpty()) { Item item = fuel.getItem(); fuel.shrink(1); if(fuel.isEmpty()) { ItemStack item1 = item.getContainerItem(fuel); this.handler.setStackInSlot(2, item1); } } } } if(this.isBurning() && this.canSmelt() && cookTime > 0) { cookTime++; if(cookTime == totalCookTime) { if(handler.getStackInSlot(3).getCount() > 0) { handler.getStackInSlot(3).grow(1); } else { handler.insertItem(3, smelting, false); } smelting = ItemStack.EMPTY; cookTime = 0; return; } } else { if(this.canSmelt() && this.isBurning()) { ItemStack output = NonEnergyForgeRecipes.getInstance().getNonEnergyForgeResult(inputs[0], inputs[1]); if(!output.isEmpty()) { smelting = output; cookTime++; inputs[0].shrink(1); inputs[1].shrink(1); handler.setStackInSlot(0, inputs[0]); handler.setStackInSlot(1, inputs[1]); } } } } private boolean canSmelt() { if(((ItemStack)this.handler.getStackInSlot(0)).isEmpty() || ((ItemStack)this.handler.getStackInSlot(1)).isEmpty()) return false; else { ItemStack result = NonEnergyForgeRecipes.getInstance().getNonEnergyForgeResult((ItemStack)this.handler.getStackInSlot(0), (ItemStack)this.handler.getStackInSlot(1)); if(result.isEmpty()) return false; else { ItemStack output = (ItemStack)this.handler.getStackInSlot(3); if(output.isEmpty()) return true; if(!output.isItemEqual(result)) return false; int res = output.getCount() + result.getCount(); return res <= 64 && res <= output.getMaxStackSize(); } } } public static int getItemBurnTime(ItemStack fuel) { if(fuel.isEmpty()) return 0; else { Item item = fuel.getItem(); if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR) { Block block = Block.getBlockFromItem(item); if (block == Blocks.WOODEN_SLAB) return 150; if (block.getDefaultState().getMaterial() == Material.WOOD) return 300; if (block == Blocks.COAL_BLOCK) return 16000; } if (item instanceof ItemTool && "WOOD".equals(((ItemTool)item).getToolMaterialName())) return 200; if (item instanceof ItemSword && "WOOD".equals(((ItemSword)item).getToolMaterialName())) return 200; if (item instanceof ItemHoe && "WOOD".equals(((ItemHoe)item).getMaterialName())) return 200; if (item == Items.STICK) return 100; if (item == Items.COAL) return 1600; if (item == Items.LAVA_BUCKET) return 20000; if (item == Item.getItemFromBlock(Blocks.SAPLING)) return 100; if (item == Items.BLAZE_ROD) return 2400; return GameRegistry.getFuelValue(fuel); } } public static boolean isItemFuel(ItemStack fuel) { return getItemBurnTime(fuel) > 0; } public boolean isUsableByPlayer(EntityPlayer player) { return this.world.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D; } public int getField(int id) { switch(id) { case 0: return this.burnTime; case 1: return this.currentBurnTime; case 2: return this.cookTime; case 3: return this.totalCookTime; default: return 0; } } public void setField(int id, int value) { switch(id) { case 0: this.burnTime = value; break; case 1: this.currentBurnTime = value; break; case 2: this.cookTime = value; break; case 3: this.totalCookTime = value; } } } Block: package com.atlas.thelostportal.objects.blocks; import java.util.Random; import com.atlas.thelostportal.Main; import com.atlas.thelostportal.objects.blocks.tileentity.TileEntityNonEnergyForge; import com.atlas.thelostportal.objects.init.ModBlocksInit; import com.atlas.thelostportal.util.Reference; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.SoundType; 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.IBlockState; import net.minecraft.entity.EntityLivingBase; 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.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class BlockNonEnergyForge extends BlockBase { public static final PropertyDirection FACING = BlockHorizontal.FACING; public static final PropertyBool BURNING = PropertyBool.create("burning"); public BlockNonEnergyForge(String name) { super(name, Material.IRON, Main.lostportaltab, 4.0F, 4.0F); setSoundType(SoundType.METAL); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(BURNING, false)); } @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(ModBlocksInit.NON_ENERGY_FORGE); } @Override public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) { return new ItemStack(ModBlocksInit.NON_ENERGY_FORGE); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if(!worldIn.isRemote) { playerIn.openGui(Main.instance, Reference.GUI_NON_ENERGY_FORGE, worldIn, pos.getX(), pos.getY(), pos.getZ()); } return true; } @Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState north = worldIn.getBlockState(pos.north()); IBlockState south = worldIn.getBlockState(pos.south()); IBlockState west = worldIn.getBlockState(pos.west()); IBlockState east = worldIn.getBlockState(pos.east()); EnumFacing face = (EnumFacing)state.getValue(FACING); if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) face = EnumFacing.SOUTH; else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) face = EnumFacing.NORTH; else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) face = EnumFacing.EAST; else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) face = EnumFacing.WEST; worldIn.setBlockState(pos, state.withProperty(FACING, face), 2); } } public static void setState(boolean active, World worldIn, BlockPos pos) { IBlockState state = worldIn.getBlockState(pos); TileEntity tileentity = worldIn.getTileEntity(pos); if(active) worldIn.setBlockState(pos, ModBlocksInit.NON_ENERGY_FORGE.getDefaultState().withProperty(FACING, state.getValue(FACING)).withProperty(BURNING, true), 3); else worldIn.setBlockState(pos, ModBlocksInit.NON_ENERGY_FORGE.getDefaultState().withProperty(FACING, state.getValue(FACING)).withProperty(BURNING, false), 3); if(tileentity != null) { tileentity.validate(); worldIn.setTileEntity(pos, tileentity); } } @Override public boolean hasTileEntity(IBlockState state) { return true; } @Override public TileEntity createTileEntity(World world, IBlockState state) { return new TileEntityNonEnergyForge(); } @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { worldIn.setBlockState(pos, this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2); } @Override public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); } @Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {BURNING,FACING}); } @Override public IBlockState getStateFromMeta(int meta) { EnumFacing facing = EnumFacing.getFront(meta); if(facing.getAxis() == EnumFacing.Axis.Y) facing = EnumFacing.NORTH; return this.getDefaultState().withProperty(FACING, facing); } @Override public int getMetaFromState(IBlockState state) { return ((EnumFacing)state.getValue(FACING)).getIndex(); } } Container: package com.atlas.thelostportal.objects.blocks.containers; import com.atlas.thelostportal.objects.blocks.recipes.NonEnergyForgeRecipes; import com.atlas.thelostportal.objects.blocks.tileentity.TileEntityNonEnergyForge; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IContainerListener; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.SlotItemHandler; public class ContainerNonEnergyForge extends Container { private final TileEntityNonEnergyForge tileentity; private int cookTime, totalCookTime, burnTime, currentBurnTime; public ContainerNonEnergyForge(InventoryPlayer player, TileEntityNonEnergyForge tileentity) { this.tileentity = tileentity; IItemHandler handler = tileentity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); this.addSlotToContainer(new SlotItemHandler(handler, 0, 26, 11)); this.addSlotToContainer(new SlotItemHandler(handler, 1, 26, 59)); this.addSlotToContainer(new SlotItemHandler(handler, 2, 7, 35)); this.addSlotToContainer(new SlotItemHandler(handler, 3, 81, 36)); for(int y = 0; y < 3; y++) { for(int x = 0; x < 9; x++) { this.addSlotToContainer(new Slot(player, x + y*9 + 9, 8 + x*18, 84 + y*18)); } } for(int x = 0; x < 9; x++) { this.addSlotToContainer(new Slot(player, x, 8 + x * 18, 142)); } } @Override public void detectAndSendChanges() { super.detectAndSendChanges(); for(int i = 0; i < this.listeners.size(); ++i) { IContainerListener listener = (IContainerListener)this.listeners.get(i); if(this.cookTime != this.tileentity.getField(2)) listener.sendWindowProperty(this, 2, this.tileentity.getField(2)); if(this.burnTime != this.tileentity.getField(0)) listener.sendWindowProperty(this, 0, this.tileentity.getField(0)); if(this.currentBurnTime != this.tileentity.getField(1)) listener.sendWindowProperty(this, 1, this.tileentity.getField(1)); if(this.totalCookTime != this.tileentity.getField(3)) listener.sendWindowProperty(this, 3, this.tileentity.getField(3)); } this.cookTime = this.tileentity.getField(2); this.burnTime = this.tileentity.getField(0); this.currentBurnTime = this.tileentity.getField(1); this.totalCookTime = this.tileentity.getField(3); } @Override @SideOnly(Side.CLIENT) public void updateProgressBar(int id, int data) { this.tileentity.setField(id, data); } @Override public boolean canInteractWith(EntityPlayer playerIn) { return this.tileentity.isUsableByPlayer(playerIn); } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack stack = ItemStack.EMPTY; Slot slot = (Slot)this.inventorySlots.get(index); if(slot != null && slot.getHasStack()) { ItemStack stack1 = slot.getStack(); stack = stack1.copy(); if(index == 3) { if(!this.mergeItemStack(stack1, 4, 40, true)) return ItemStack.EMPTY; slot.onSlotChange(stack1, stack); } else if(index != 2 && index != 1 && index != 0) { Slot slot1 = (Slot)this.inventorySlots.get(index + 1); if(!NonEnergyForgeRecipes.getInstance().getNonEnergyForgeResult(stack1, slot1.getStack()).isEmpty()) { if(!this.mergeItemStack(stack1, 0, 2, false)) { return ItemStack.EMPTY; } else if(TileEntityNonEnergyForge.isItemFuel(stack1)) { if(!this.mergeItemStack(stack1, 2, 3, false)) return ItemStack.EMPTY; } else if(TileEntityNonEnergyForge.isItemFuel(stack1)) { if(!this.mergeItemStack(stack1, 2, 3, false)) return ItemStack.EMPTY; } else if(TileEntityNonEnergyForge.isItemFuel(stack1)) { if(!this.mergeItemStack(stack1, 2, 3, false)) return ItemStack.EMPTY; } else if(index >= 4 && index < 31) { if(!this.mergeItemStack(stack1, 31, 40, false)) return ItemStack.EMPTY; } else if(index >= 31 && index < 40 && !this.mergeItemStack(stack1, 4, 31, false)) { return ItemStack.EMPTY; } } } else if(!this.mergeItemStack(stack1, 4, 40, false)) { return ItemStack.EMPTY; } if(stack1.isEmpty()) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if(stack1.getCount() == stack.getCount()) return ItemStack.EMPTY; slot.onTake(playerIn, stack1); } return stack; } } GUI: package com.atlas.thelostportal.objects.blocks.guis; import com.atlas.thelostportal.objects.blocks.containers.ContainerNonEnergyForge; import com.atlas.thelostportal.objects.blocks.tileentity.TileEntityNonEnergyForge; import com.atlas.thelostportal.util.Reference; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; public class GuiNonEnergyForge extends GuiContainer { private static final ResourceLocation TEXTURES = new ResourceLocation(Reference.MOD_ID + ":textures/gui/non_energy_forge.png"); private final InventoryPlayer player; private final TileEntityNonEnergyForge tileentity; public GuiNonEnergyForge(InventoryPlayer player, TileEntityNonEnergyForge tileentity) { super(new ContainerNonEnergyForge(player, tileentity)); this.player = player; this.tileentity = tileentity; } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { String tileName = this.tileentity.getDisplayName().getUnformattedText(); this.fontRenderer.drawString(tileName, (this.xSize / 2 - this.fontRenderer.getStringWidth(tileName) / 2) + 3, 8, 4210752); this.fontRenderer.drawString(this.player.getDisplayName().getUnformattedText(), 122, this.ySize - 96 + 2, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); this.mc.getTextureManager().bindTexture(TEXTURES); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); if(TileEntityNonEnergyForge.isBurning(tileentity)) { int k = this.getBurnLeftScaled(13); this.drawTexturedModalRect(this.guiLeft + 8, this.guiTop + 54 + 12 - k, 176, 12 - k, 14, k + 1); } int l = this.getCookProgressScaled(24); this.drawTexturedModalRect(this.guiLeft + 44, this.guiTop + 36, 176, 14, l + 1, 16); } private int getBurnLeftScaled(int pixels) { int i = this.tileentity.getField(1); if(i == 0) i = 200; return this.tileentity.getField(0) * pixels / i; } private int getCookProgressScaled(int pixels) { int i = this.tileentity.getField(2); int j = this.tileentity.getField(3); return j != 0 && i != 0 ? i * pixels / j : 0; } } and Recipes: package com.atlas.thelostportal.objects.blocks.recipes; import java.util.Map; import java.util.Map.Entry; import com.atlas.thelostportal.objects.init.ModBlocksInit; import com.atlas.thelostportal.objects.init.ModItemsInit; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Maps; import com.google.common.collect.Table; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; public class NonEnergyForgeRecipes { private static final NonEnergyForgeRecipes INSTANCE = new NonEnergyForgeRecipes(); private final Table<ItemStack, ItemStack, ItemStack> smeltingList = HashBasedTable.<ItemStack, ItemStack, ItemStack>create(); private final Map<ItemStack, Float> experienceList = Maps.<ItemStack, Float>newHashMap(); public static NonEnergyForgeRecipes getInstance() { return INSTANCE; } private NonEnergyForgeRecipes() { addNonEnergyForgeRecipe(new ItemStack(Items.IRON_SWORD), new ItemStack(Items.IRON_NUGGET), new ItemStack(ModItemsInit.BASIC_BLADE), 5.0F); } public void addNonEnergyForgeRecipe(ItemStack input1, ItemStack input2, ItemStack result, float experience) { if(getNonEnergyForgeResult(input1, input2) != ItemStack.EMPTY) return; this.smeltingList.put(input1, input2, result); this.experienceList.put(result, Float.valueOf(experience)); } public ItemStack getNonEnergyForgeResult(ItemStack input1, ItemStack input2) { for(Entry<ItemStack, Map<ItemStack, ItemStack>> entry : this.smeltingList.columnMap().entrySet()) { if(this.compareItemStacks(input1, (ItemStack)entry.getKey())) { for(Entry<ItemStack, ItemStack> ent : entry.getValue().entrySet()) { if(this.compareItemStacks(input2, (ItemStack)ent.getKey())) { return (ItemStack)ent.getValue(); } } } } return ItemStack.EMPTY; } private boolean compareItemStacks(ItemStack stack1, ItemStack stack2) { return stack2.getItem() == stack1.getItem() && (stack2.getMetadata() == 32767 || stack2.getMetadata() == stack1.getMetadata()); } public Table<ItemStack, ItemStack, ItemStack> getDualSmeltingList() { return this.smeltingList; } public float getNonEnergyForgeExperience(ItemStack stack) { for (Entry<ItemStack, Float> entry : this.experienceList.entrySet()) { if(this.compareItemStacks(stack, (ItemStack)entry.getKey())) { return ((Float)entry.getValue()).floatValue(); } } return 0.0F; } }
-
How do i make a block colorable exactly like the leather-armour?
Blue_Atlas replied to Drachenbauer's topic in Modder Support
I believe a version of what you are trying to do is this mod, right?