Add honey fluid - Currently does not render! Seems like this is a problem affecting all forge fluids in 1.8

This commit is contained in:
Cheeserolls 2015-04-29 12:26:22 +01:00
parent 268b90ba12
commit 509872483e
8 changed files with 135 additions and 49 deletions

View File

@ -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;
}

View File

@ -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<String> fluidsToTextureStitch = new ArrayList<String>();
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

View File

@ -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));
}
}
}

View File

@ -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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

@ -0,0 +1,5 @@
{
"animation": {
"frametime": 3
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -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
]
}
}