Jump to content

Recommended Posts

Posted

I been having trouble getting the items not to duplicate.

In my mod there's a liquid block (Hot Water) that has the property of cooking food when the food thrown into it. The cooking works but the liquid also creates extra unpickupable item that would disappear after a relog.

Here's the code of my main class and the hot water block class.

 

BlockHotWater Class

public class BlockHotWater extends BlockFluidClassic{

protected IIcon stillWater;
protected IIcon flowingWater;
protected World world;
protected Entity entity;
FoodList list = new FoodList();

public BlockHotWater(Fluid fluid, Material material) {
	super(fluid, material);
	setCreativeTab(CreativeTabs.tabMisc);
}

public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
    {
	if(!(entity instanceof EntityItem)){
        entity.attackEntityFrom(HotWater_Main.Boiled, 2.0F);
        WaterEffect(world,  x,  y,  z, 1);
	}
	if(entity instanceof EntityItem){
	CookingEffect(world, x, y , z, entity);
	}
    }

public void CookingEffect(World world, int x, int y, int z, Entity entity){
	if(((EntityItem)entity).getEntityItem().getItem() == Items.chicken) {
		WaterEffect(world, x, y, z, 2);
		entity.setDead();
		entity.entityDropItem(new ItemStack(Items.cooked_chicken), 0F);
	}
	if(((EntityItem)entity).getEntityItem().getItem() == Items.porkchop){
		WaterEffect(world, x, y, z, 2);
		entity.setDead();
		entity.entityDropItem(new ItemStack(Items.cooked_porkchop), 0F);
	}
        if(((EntityItem)entity).getEntityItem().getItem() == Items.beef){
        	WaterEffect(world, x, y, z, 2);
        	entity.setDead();
        	entity.entityDropItem(new ItemStack(Items.cooked_beef), 0F);
	}
        if(((EntityItem)entity).getEntityItem().getItem() == Items.potato || ((EntityItem)entity).getEntityItem().getItem() == Items.poisonous_potato){
        	WaterEffect(world, x, y, z, 2);
        	entity.setDead();
        	entity.entityDropItem(new ItemStack(Items.baked_potato), 0F);
	}
        if(((EntityItem)entity).getEntityItem().getItem() == Items.fish){
        	if(((EntityItem)entity).getEntityItem().getItemDamage() == 0){
        	 WaterEffect(world, x, y, z, 2);
        	 entity.setDead();
        	 entity.entityDropItem(new ItemStack(Items.cooked_fished, 1), 0F);
        	}
        	if(((EntityItem)entity).getEntityItem().getItemDamage() == 1){
           	 WaterEffect(world, x, y, z, 2);
           	 entity.setDead();
           	 entity.entityDropItem(new ItemStack(Items.cooked_fished, 1, 1), 0F);
           	}
        	
        }
}

 protected void WaterEffect(World world, int x, int y, int z, int type)
    {
	 world.playSoundEffect((float)x + 0.5F, (float)y + 0.5F, (float)z + 0.5F, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
        for(int l = 0; l < 8; l++)
        	if(type == 1){
        	world.spawnParticle("largesmoke", (double)x + Math.random(), (double)y + 1.2D, (double)z + Math.random(), 0.0D, 0.0D, 0.0D);
        	}
                if(type == 2){
                	world.spawnParticle("cloud", (double)x + Math.random(), (double)y + 1.2D, (double)z + Math.random(), 0.0D, 0.0D, 0.0D);
                }
    }	 

@Override
public IIcon getIcon (int side, int meta){
	return (IIcon) ((side == 0 || side == 1) ? stillWater : flowingWater);
}

    @Override
    public void registerBlockIcons(IIconRegister register) {
            stillWater = register.registerIcon("hot_water:hot_water_still");
            flowingWater = register.registerIcon("hot_water:hot_water_flow");
    }
   

}

 

Main Class

@Mod(name = "Hot Water Mod", modid = HotWater_Main.MODID, version = HotWater_Main.VERSION)
public class HotWater_Main {

public static final String MODID = "hot_water";
public static final String VERSION = "1.0";
private static final String Water_Name = "hot_water";
private static final String SuperLava_Name = "super_lava";
private static final String SpringWater_Name = "hot_spring_water";

public Fluid hotWater = new Fluid(Water_Name).setDensity(999).setTemperature(373).setViscosity(682);
public static Block BlockHotWater;
public static Block BlockSpringWater;
public static Item hot_water_bucket; 
public static DamageSource Boiled = new DamageSource("hot_water.boiled");

public Fluid superlava = new Fluid(SuperLava_Name).setDensity(999).setTemperature(6150).setViscosity(682);
public static Block BlockSuperLava;
public static Item superlava_bucket; 
public static DamageSource Melted = new DamageSource("hot_water.Melted").setFireDamage();
public static final Material Superlava = new MaterialLiquid(MapColor.tntColor);

public static Fluid springWater = new Fluid(SpringWater_Name).setDensity(999).setTemperature(373).setViscosity(682);

public static Item spring_water_bucket; 

public static BiomeGenBase BiomeHotSpring;

@EventHandler
public void PreInit(FMLPreInitializationEvent event){

	Configuration config = new Configuration(event.getSuggestedConfigurationFile());
    int BiomeID = config.get(Configuration.CATEGORY_GENERAL, "BiomeID", 35).getInt();

	FMLLog.info("[Hot Water] Registering the Hot Water, Spring Water and Super Lava Fluid");
	FluidRegistry.registerFluid(hotWater);
	FluidRegistry.registerFluid(superlava);
	FluidRegistry.registerFluid(springWater);
	FMLLog.info("[Hot Water] Hot Water, Spring Water and Super Lava fluid Registered");
	BlockSpringWater = new BlockSpringWater(springWater, Material.water).setBlockName(SpringWater_Name).setHardness(100F);
	FMLLog.info("[Hot Water] Registering the Hot Water, Spring Water and Super Lava Block");	
	BlockHotWater = new BlockHotWater(hotWater, Material.water).setBlockName(Water_Name).setHardness(100F);

	BlockSuperLava = new BlockSuperLava(superlava, Material.lava).setBlockName(SuperLava_Name).setHardness(100F).setLightLevel(10.0F);
	GameRegistry.registerBlock(BlockSuperLava, SuperLava_Name);
	GameRegistry.registerBlock(BlockHotWater, Water_Name);
	GameRegistry.registerBlock(BlockSpringWater, SpringWater_Name);
	FMLLog.info("[Hot Water] Hot Water, Spring Water and Super Lava Block Registered");

	FMLLog.info("[Hot Water] Registering Hot Water, Spring Water and Super Lava Bucket");
	hot_water_bucket = new ItemBucket(BlockHotWater).setTextureName("hot_water:bucket_hot_water").setUnlocalizedName("bucket_hot_water");
	GameRegistry.registerItem(hot_water_bucket, "bucket_hot_water", MODID);
	FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack(Water_Name, FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(hot_water_bucket), new ItemStack(Items.bucket));

	superlava_bucket = new ItemBucket(BlockSuperLava).setTextureName("bucket_lava").setUnlocalizedName("bucket_superlava");
	GameRegistry.registerItem(superlava_bucket, "bucket_superlava", MODID);
	FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack(SuperLava_Name, FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(superlava_bucket), new ItemStack(Items.bucket));

	spring_water_bucket = new ItemBucket(BlockSpringWater).setTextureName("hot_water:bucket_hot_spring_water").setUnlocalizedName("bucket_spring_water");
	GameRegistry.registerItem(spring_water_bucket, "bucket_spring_water", MODID);
	FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack(SpringWater_Name, FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(spring_water_bucket), new ItemStack(Items.bucket));
	FMLLog.info("[Hot Water] Hot Water Bucket, Spring Water and Super Lava Registered");

	FMLLog.info("[Hot Water] Registering Buildcraft's BucketFill Event");
	BucketHandler.INSTANCE.buckets.put(BlockHotWater, hot_water_bucket);
    BucketHandler.INSTANCE.buckets.put(BlockSuperLava, superlava_bucket);
    BucketHandler.INSTANCE.buckets.put(BlockSpringWater, spring_water_bucket);
	MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE);
    FMLLog.info("[Hot Water] Buildcraft's BucketFill Event Registered");
    
    config.load();
    
    FMLLog.info("[Hot Water] Adding new Spring Biome (BECUASE WORLDGEN IS HARD D:)");
    BiomeHotSpring = new BiomeHotSpring(BiomeID).setEnableSnow().setBiomeName("Hot Springs").setHeight(new Height(0F, 0F));
    BiomeDictionary.registerBiomeType(BiomeHotSpring, Type.FROZEN);
    FMLLog.info("[Hot Water] Spring Biome Added");

    config.save();
    
	FMLLog.info("[Hot Water] Registering Cooking Recipes and Fuel");
	GameRegistry.addSmelting(Items.water_bucket, new ItemStack(hot_water_bucket), 0.3F);
	GameRegistry.addSmelting(Items.lava_bucket, new ItemStack(superlava_bucket), 0.5F);
	GameRegistry.registerFuelHandler(new FuelHandler());
	FMLLog.info("[Hot Water] Cooking Recipes and Fuel Registered");

}

}

A video of it to help you see the problem

[embed=425,349]

[/embed]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I have no idea what the flip is going on, I can load the modpack just fine at forge 42.2.0 but any forge version above it insta-crashes with exit code 1. Can somebody tell me what's going on, this is minecraft 1.20.1 Latest.log: https://pastebin.com/pBUL1ZFa
    • does anyone know how to incorporate custom noise settings into a custom dimension through the use of datagen, I have created a custon json file for the noise settings that I want but I just don't know how to get it to register with the generated json file of the custom dimension.   here is the code for the dimension class package net.hurst.lustria.worldgen.dimension; import com.mojang.datafixers.util.Pair; import net.hurst.lustria.Lustria; import net.hurst.lustria.worldgen.biome.ModBiomes; import net.hurst.lustria.worldgen.registries.LustriaNoiseSettings; import net.minecraft.core.HolderGetter; import net.minecraft.core.registries.Registries; import net.minecraft.data.worldgen.BootstapContext; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; import net.minecraft.util.valueproviders.ConstantInt; import net.minecraft.world.level.Level; import net.minecraft.world.level.biome.*; import net.minecraft.world.level.dimension.BuiltinDimensionTypes; import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; import java.util.List; import java.util.OptionalLong; public class ModDimensions { public static final ResourceKey<LevelStem> LUSTRIA_KEY = ResourceKey.create(Registries.LEVEL_STEM, ResourceLocation.fromNamespaceAndPath(Lustria.MOD_ID, "lustriadim")); public static final ResourceKey<Level> LUSTRIA_LEVEL_KEY = ResourceKey.create(Registries.DIMENSION, ResourceLocation.fromNamespaceAndPath(Lustria.MOD_ID, "lustriadim")); public static final ResourceKey<DimensionType> LUSTRIA_DIM_TYPE = ResourceKey.create(Registries.DIMENSION_TYPE, ResourceLocation.fromNamespaceAndPath(Lustria.MOD_ID, "lustriadim_type")); public static void bootstrapType(BootstapContext<DimensionType> context) { context.register(LUSTRIA_DIM_TYPE, new DimensionType( OptionalLong.of(12000), // fixedTime false, // hasSkylight true, // hasCeiling false, // ultraWarm false, // natural 1.0, // coordinateScale true, // bedWorks false, // respawnAnchorWorks -64, // minY 256, // height 256, // logicalHeight BlockTags.INFINIBURN_OVERWORLD, // infiniburn BuiltinDimensionTypes.OVERWORLD_EFFECTS, // effectsLocation 0.0f, // ambientLight new DimensionType.MonsterSettings(false, false, ConstantInt.of(0), 0))); } public static void bootstrapStem(BootstapContext<LevelStem> context) { HolderGetter<Biome> biomeRegistry = context.lookup(Registries.BIOME); HolderGetter<DimensionType> dimTypes = context.lookup(Registries.DIMENSION_TYPE); HolderGetter<NoiseGeneratorSettings> noiseGenSettings = context.lookup(Registries.NOISE_SETTINGS); NoiseBasedChunkGenerator wrappedChunkGenerator = new NoiseBasedChunkGenerator( new FixedBiomeSource(biomeRegistry.getOrThrow(Biomes.BEACH)), noiseGenSettings.getOrThrow(NoiseGeneratorSettings.CAVES)); NoiseBasedChunkGenerator noiseBasedChunkGenerator = new NoiseBasedChunkGenerator( MultiNoiseBiomeSource.createFromList( new Climate.ParameterList<>(List.of(Pair.of( Climate.parameters(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F), biomeRegistry.getOrThrow(Biomes.BEACH)), Pair.of( Climate.parameters(0.1F, 0.2F, 0.0F, 0.2F, 0.0F, 0.0F, 0.0F), biomeRegistry.getOrThrow(Biomes.BIRCH_FOREST)), Pair.of( Climate.parameters(0.3F, 0.6F, 0.1F, 0.1F, 0.0F, 0.0F, 0.0F), biomeRegistry.getOrThrow(Biomes.OCEAN)), Pair.of( Climate.parameters(0.4F, 0.3F, 0.2F, 0.1F, 0.0F, 0.0F, 0.0F), biomeRegistry.getOrThrow(Biomes.DARK_FOREST)) ))), noiseGenSettings.getOrThrow(NoiseGeneratorSettings.CAVES)); LevelStem stem = new LevelStem(dimTypes.getOrThrow(ModDimensions.LUSTRIA_DIM_TYPE), noiseBasedChunkGenerator); context.register(LUSTRIA_KEY, stem); } } minecraft version is 1.20.1
    • Please read the FAQ (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/) and post logs as described there using a site like https://mclo.gs and post the link to it here. It may have the information required to solve your problem.  
    • the error code comes up when i trry to run it and ive tried to fix it but i cant  
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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