Jump to content

Corey

Members
  • Posts

    59
  • Joined

  • Last visited

Everything posted by Corey

  1. It's currently just a static field: public static final UniversalBucket CLAY_BUCKET = new UniversalBucket(); The class it's in is initialized on the line immediately preceding the code I pasted above. See source here: https://github.com/LordMonoxide/gradient/blob/master.%2337.buckets/src/main/java/lordmonoxide/gradient/items/GradientItems.java#L205 CLAY_BUCKET is defined on line 96. Note: it's a god damned mess, it started off as a learning mod and needs to be refactored
  2. I copied the registration code from ForgeModContainer: CLAY_BUCKET.setUnlocalizedName("clay_bucket"); event.getRegistry().register(CLAY_BUCKET.setRegistryName(GradientMod.MODID, "clay_bucket")); MinecraftForge.EVENT_BUS.register(CLAY_BUCKET); I'm guessing it's not necessary to register the event handlers again here since Forge already does, but I get the same error if that line is commented out.
  3. The universal bucket is great and all (it's what my clay buckets currently turn into once they harden), but I'd like to have them come out as actual clay buckets. My first attempt was to just create my own instance of the universal bucket with a modified unlocalised/registry name, which yielded: [11:19:05] [main/WARN] [FML/]: Registry Item: Override did not have an associated owner object. Name: gradient:clay_bucket Value: lordmonoxide.gradient.items.ClayBucket@72188b01 In case Forge was using the actually class object in one of its maps, I tried extending it, but got the same issue. I don't want to override the bucket, I want to create a second, non-metal bucket. Anyone have any suggestions, short of copying-and-pasting the universal bucket class?
  4. Thanks, I took a look at the Entity class and see exactly what you're talking about... For the time being, I'll just switch the material to Material.WATER.
  5. I have several fluids defined in my mod, that all work perfectly, except for the fact that entities pass through them as if they were air. I've been looking at code from other mods with fluids, (IC2 applies potion effects, BC uses entity.setInWeb) but this can't be the "correct" way to do it, right? I've searched for tutorials, and none seem to mention anything about having to code this entity interaction manually, which leads me to believe I may have done something wrong. Can anyone point me in the right direction? My registration code is fairly straight-forward: private static void registerFluidForMetal(final IForgeRegistry<Block> registry, final GradientMetals.Metal metal) { final Fluid fluid; if(FluidRegistry.isFluidRegistered(metal.name)) { fluid = FluidRegistry.getFluid(metal.name); } else { fluid = new Fluid(metal.name, GradientMod.resource("blocks/fluid_" + metal.name), GradientMod.resource("blocks/fluid_" + metal.name + "_flowing")) .setDensity(3000) .setLuminosity(9) .setViscosity(5000) .setTemperature((int)(metal.meltTemp + 273.15)); FluidRegistry.registerFluid(fluid); } FluidRegistry.addBucketForFluid(fluid); final Block block = new BlockMetalFluid(fluid); if(fluid.getBlock() == null) { fluid.setBlock(block); } registry.register(block); metal.fluid = fluid; } And the BlockMetalFluid code is as follows: public class BlockMetalFluid extends BlockFluidClassic { public BlockMetalFluid(final Fluid fluid) { super(fluid, GradientBlocks.MATERIAL_LIQUID_METAL); this.setRegistryName(fluid.getUnlocalizedName()); this.setUnlocalizedName(fluid.getUnlocalizedName()); fluid.setBlock(this); } }
  6. Cool, that sounds like a good solution. Thanks for the help. For anyone else looking for an answer to the second question: until there's a better way, I just ended up defining a _constant called #SAND that includes sand with data 0 and 1.
  7. I assume I'm just doing something wrong here. My test recipe shows up in NEI, but it doesn't show up in the recipe book and can't be crafted. Here's the code: @SubscribeEvent public static void registerRecipes(final RegistryEvent.Register<IRecipe> event) { event.getRegistry().register( new ShapelessRecipes( "gradient", new ItemStack(Items.APPLE), NonNullList.from(null, Ingredient.fromStacks(new ItemStack(Items.CLAY_BALL)), Ingredient.fromStacks(new ItemStack(Blocks.SAND, 1, OreDictionary.WILDCARD_VALUE)) ) ).setRegistryName(GradientMod.MODID, "recipe.tests") ); } For the record, I want to move some of my json recipes back to code because prior to 1.12, many recipes were automatically generated based on melting point, hardness, etc. With json recipes, whenever I add a new cast/metal/tool/whatever I have to add quite a few files manually. Sub-question: Was wildcard support removed from json recipes? When I updated from 1.12 to 1.12.2, this recipe stopped working: { "type": "minecraft:crafting_shapeless", "result": { "item": "gradient:clay_cast_unhardened", "data": 0 }, "ingredients": [{ "item": "minecraft:clay_ball" }, { "item": "minecraft:sand", "data": 32767 }] } There were no other changes. When data is changed from 32767 to 0, the recipe works (but obviously only supports regular sand).
  8. [cross-posted from Minecraft Forum] I'm in the process of adding a firepit - to make it, you click on the ground with a stick. That part was easy enough. I'm using PlayerInteractEvent.RightClickBlock. The only problem is, it doesn't account for blocks that can be activated, such as doors or containers. If you right click on a door, for example, it places the stick as a firepit. Is there a way to check and see if the block you're right clicking on can be activated? Alternatively, is there a better solution to this than using the RightClickBlock event? I had to copy a chunk of code from ItemBlock.java, and I'd much rather use code that's already there, rather than duplicate it into my own code. PS. This is my first Minecraft mod, but I'm a well-established software engineer. Current code is as follows. It's a bit rough around the edges - I'm in hack mode. @SubscribeEvent public void onRightClickBlock(PlayerInteractEvent.RightClickBlock event) { if(event.getItemStack() != null) { Item item = event.getItemStack().getItem(); if(item == Items.STICK) { if(event.getWorld().getBlockState(event.getPos()).getBlock() == ModBlocks.FIRE_PIT) { } else { //TODO: Don't do this if it's something you can interact with... door, container, etc. World world = event.getWorld(); BlockPos pos = event.getPos(); ItemStack stack = event.getItemStack(); EntityPlayer player = event.getEntityPlayer(); EnumFacing facing = event.getFace(); IBlockState iblockstate = world.getBlockState(pos); Block block = iblockstate.getBlock(); if(!block.isReplaceable(world, pos)) { pos = pos.offset(facing); } if(stack.stackSize != 0 && player.canPlayerEdit(pos, facing, stack) && world.canBlockBePlaced(ModBlocks.FIRE_PIT, pos, false, facing, null, stack)) { IBlockState iblockstate1 = ModBlocks.FIRE_PIT.onBlockPlaced(world, pos, facing, 0, 0, 0, 0, player); if(placeBlockAt(stack, player, world, pos, iblockstate1)) { SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player); world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); event.setUseItem(Result.ALLOW); } } } } } } public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, IBlockState newState) { if(!world.setBlockState(pos, newState, 3)) { return false; } IBlockState state = world.getBlockState(pos); if(state.getBlock() == newState.getBlock()) { ItemBlock.setTileEntityNBT(world, player, pos, stack); newState.getBlock().onBlockPlacedBy(world, pos, state, player, stack); } return true; }
×
×
  • Create New...

Important Information

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