diff --git a/src/main/java/biomesoplenty/api/block/BOPBlocks.java b/src/main/java/biomesoplenty/api/block/BOPBlocks.java index 348cf1175..92d4305e2 100644 --- a/src/main/java/biomesoplenty/api/block/BOPBlocks.java +++ b/src/main/java/biomesoplenty/api/block/BOPBlocks.java @@ -9,6 +9,7 @@ package biomesoplenty.api.block; import net.minecraft.block.Block; +import net.minecraftforge.fluids.Fluid; public class BOPBlocks { @@ -130,4 +131,6 @@ public class BOPBlocks public static Block honey_block; + public static Block honey; + public static Fluid honey_fluid; } diff --git a/src/main/java/biomesoplenty/client/handler/ModelBakeHandler.java b/src/main/java/biomesoplenty/client/handler/ModelBakeHandler.java index 0faffa871..8a821df9f 100644 --- a/src/main/java/biomesoplenty/client/handler/ModelBakeHandler.java +++ b/src/main/java/biomesoplenty/client/handler/ModelBakeHandler.java @@ -8,21 +8,29 @@ package biomesoplenty.client.handler; +import java.util.ArrayList; +import java.util.List; + import biomesoplenty.client.model.ModelBiomeFinder; import biomesoplenty.client.texture.TextureAnimationFrame; import biomesoplenty.client.util.TextureUtils; +import biomesoplenty.core.BiomesOPlenty; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.resources.model.IBakedModel; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.util.IRegistry; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class ModelBakeHandler { public static final ModelResourceLocation BIOME_FINDER = new ModelResourceLocation("biomesoplenty:biome_finder", "inventory"); + public static List fluidsToTextureStitch = new ArrayList(); + private TextureAnimationFrame[] biomeFinderFrames; @SubscribeEvent @@ -31,6 +39,19 @@ public class ModelBakeHandler TextureMap map = event.map; biomeFinderFrames = TextureUtils.splitAnimatedTexture(map, "biomesoplenty:items/biome_finder", 12); + + for (String name : fluidsToTextureStitch) + { + Fluid fluid = FluidRegistry.getFluid(name); + if (fluid == null) + { + BiomesOPlenty.logger.error("No fluid found with name "+name); + } + else + { + fluid.setIcons(map.getAtlasSprite("biomesoplenty:blocks/"+name+"_still"), map.getAtlasSprite("biomesoplenty:blocks/"+name+"_flowing")); + } + } } @SubscribeEvent diff --git a/src/main/java/biomesoplenty/common/fluids/blocks/BlockHoneyFluid.java b/src/main/java/biomesoplenty/common/fluids/blocks/BlockHoneyFluid.java new file mode 100644 index 000000000..12ae29f38 --- /dev/null +++ b/src/main/java/biomesoplenty/common/fluids/blocks/BlockHoneyFluid.java @@ -0,0 +1,32 @@ +package biomesoplenty.common.fluids.blocks; + +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fluids.BlockFluidFinite; +import net.minecraftforge.fluids.Fluid; + +public class BlockHoneyFluid extends BlockFluidFinite +{ + + public BlockHoneyFluid(Fluid fluid) + { + super(fluid, Material.water); + this.setLightOpacity(1); + } + + // TODO: check we need this - Does Forge's fluid already handle it through viscosity? + @Override + public void onEntityCollidedWithBlock(World world, BlockPos pos, Entity entity) + { + if (entity instanceof EntityLivingBase) + { + ((EntityLivingBase)entity).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200, 2)); + } + } + +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/init/ModBlocks.java b/src/main/java/biomesoplenty/common/init/ModBlocks.java index e7b8eadae..adbbd84ce 100644 --- a/src/main/java/biomesoplenty/common/init/ModBlocks.java +++ b/src/main/java/biomesoplenty/common/init/ModBlocks.java @@ -12,67 +12,28 @@ import static biomesoplenty.api.block.BOPBlocks.*; import net.minecraft.block.Block; import net.minecraft.block.BlockSlab; import net.minecraft.block.material.Material; +import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.block.statemap.IStateMapper; +import net.minecraft.client.renderer.block.statemap.StateMap; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemDoor; import net.minecraft.item.ItemSlab; +import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.fluids.BlockFluidBase; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fml.common.registry.GameData; import net.minecraftforge.fml.common.registry.GameRegistry; import biomesoplenty.api.block.BOPWoodEnums.AllWoods; import biomesoplenty.api.block.IBOPBlock; import biomesoplenty.api.item.BOPItems; -import biomesoplenty.common.block.BlockAsh; -import biomesoplenty.common.block.BlockBOPDirt; -import biomesoplenty.common.block.BlockBOPDoor; -import biomesoplenty.common.block.BlockBOPDoubleWoodSlab0; -import biomesoplenty.common.block.BlockBOPDoubleWoodSlab1; -import biomesoplenty.common.block.BlockBOPFence; -import biomesoplenty.common.block.BlockBOPFenceGate; -import biomesoplenty.common.block.BlockBOPFlower1; -import biomesoplenty.common.block.BlockBOPFlower2; -import biomesoplenty.common.block.BlockBOPGeneric; -import biomesoplenty.common.block.BlockBOPGrass; -import biomesoplenty.common.block.BlockBOPHalfWoodSlab0; -import biomesoplenty.common.block.BlockBOPHalfWoodSlab1; -import biomesoplenty.common.block.BlockBOPLeaves0; -import biomesoplenty.common.block.BlockBOPLeaves1; -import biomesoplenty.common.block.BlockBOPLeaves2; -import biomesoplenty.common.block.BlockBOPLeaves3; -import biomesoplenty.common.block.BlockBOPLeaves4; -import biomesoplenty.common.block.BlockBOPLeaves5; -import biomesoplenty.common.block.BlockBOPLilypad; -import biomesoplenty.common.block.BlockBOPLog0; -import biomesoplenty.common.block.BlockBOPLog1; -import biomesoplenty.common.block.BlockBOPLog2; -import biomesoplenty.common.block.BlockBOPLog3; -import biomesoplenty.common.block.BlockBOPMushroom; -import biomesoplenty.common.block.BlockBOPPlanks; -import biomesoplenty.common.block.BlockBOPPlanks0; -import biomesoplenty.common.block.BlockBOPSapling0; -import biomesoplenty.common.block.BlockBOPSapling1; -import biomesoplenty.common.block.BlockBOPSapling2; -import biomesoplenty.common.block.BlockBOPStairs; -import biomesoplenty.common.block.BlockBOPStone; -import biomesoplenty.common.block.BlockBOPVine; -import biomesoplenty.common.block.BlockBamboo; -import biomesoplenty.common.block.BlockBones; -import biomesoplenty.common.block.BlockCoral; -import biomesoplenty.common.block.BlockCrystal; -import biomesoplenty.common.block.BlockBOPDoublePlant; -import biomesoplenty.common.block.BlockFlesh; -import biomesoplenty.common.block.BlockBOPPlant0; -import biomesoplenty.common.block.BlockBOPPlant1; -import biomesoplenty.common.block.BlockFruit; -import biomesoplenty.common.block.BlockGem; -import biomesoplenty.common.block.BlockGemOre; -import biomesoplenty.common.block.BlockHive; -import biomesoplenty.common.block.BlockHoney; -import biomesoplenty.common.block.BlockMud; -import biomesoplenty.common.block.BlockStoneFormations; -import biomesoplenty.common.block.BlockTurnip; +import biomesoplenty.client.handler.ModelBakeHandler; +import biomesoplenty.common.block.*; import biomesoplenty.common.command.BOPCommand; +import biomesoplenty.common.fluids.blocks.BlockHoneyFluid; import biomesoplenty.common.util.block.BlockStateUtils; import biomesoplenty.common.util.inventory.CreativeTabBOP; import biomesoplenty.core.BiomesOPlenty; @@ -227,6 +188,25 @@ public class ModBlocks honey_block = registerBlock( new BlockHoney(), "honey_block" ); + + // TODO: make the honey render! at the moment, no forge fluids are rendering in 1.8, they're invisible + honey_fluid = new Fluid("honey"); + honey_fluid.setViscosity(1500); + FluidRegistry.registerFluid(honey_fluid); + honey = registerFluidBlock(honey_fluid, new BlockHoneyFluid(honey_fluid), "honey"); + + } + + + public static Block registerFluidBlock(Fluid fluid, BlockFluidBase fluidBlock, String name) + { + Block block = GameRegistry.registerBlock(fluidBlock, null, name); + // use a custom state mapper which will ignore the LEVEL property + IStateMapper custom_mapper = (new StateMap.Builder()).addPropertiesToIgnore(new IProperty[] {BlockFluidBase.LEVEL}).build(); + ModelLoader.setCustomStateMapper(block, custom_mapper); + fluid.setBlock(fluidBlock); + ModelBakeHandler.fluidsToTextureStitch.add(name); + return block; } diff --git a/src/main/resources/assets/biomesoplenty/textures/blocks/honey_flowing.png b/src/main/resources/assets/biomesoplenty/textures/blocks/honey_flowing.png new file mode 100644 index 000000000..b5865f15b Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/blocks/honey_flowing.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/blocks/honey_flowing.png.mcmeta b/src/main/resources/assets/biomesoplenty/textures/blocks/honey_flowing.png.mcmeta new file mode 100644 index 000000000..8e55e43ba --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/textures/blocks/honey_flowing.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/src/main/resources/assets/biomesoplenty/textures/blocks/honey_still.png b/src/main/resources/assets/biomesoplenty/textures/blocks/honey_still.png new file mode 100644 index 000000000..6b69e8b2c Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/blocks/honey_still.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/blocks/honey_still.png.mcmeta b/src/main/resources/assets/biomesoplenty/textures/blocks/honey_still.png.mcmeta new file mode 100644 index 000000000..04867655f --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/textures/blocks/honey_still.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +}