mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Fix various errors in text mods.
This commit is contained in:
1 parent
74b2c3dfe6
commit
ed8a8b415b
8 files changed
+79
-321
No files matched your search
@@ -19,6 +19,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
@@ -81,6 +82,7 @@ public class DynBucketTest
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
@@ -113,6 +115,7 @@ public class DynBucketTest
|
||||
//MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void registerFluidContainer(Fluid fluid, int meta)
|
||||
{
|
||||
if (fluid == null)
|
||||
@@ -123,6 +126,7 @@ public class DynBucketTest
|
||||
FluidContainerRegistry.registerFluidContainer(fs, stack, new ItemStack(Items.bucket));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void registerFluidContainer2(Fluid fluid, int meta)
|
||||
{
|
||||
if (fluid == null)
|
||||
@@ -136,16 +140,16 @@ public class DynBucketTest
|
||||
@SubscribeEvent
|
||||
public void onBucketFill(FillBucketEvent event)
|
||||
{
|
||||
IBlockState state = event.world.getBlockState(event.target.getBlockPos());
|
||||
IBlockState state = event.getWorld().getBlockState(event.getTarget().getBlockPos());
|
||||
if (state.getBlock() instanceof IFluidBlock)
|
||||
{
|
||||
Fluid fluid = ((IFluidBlock) state.getBlock()).getFluid();
|
||||
FluidStack fs = new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME);
|
||||
|
||||
ItemStack filled = FluidContainerRegistry.fillFluidContainer(fs, event.current);
|
||||
ItemStack filled = FluidContainerRegistry.fillFluidContainer(fs, event.getEmptyBucket());
|
||||
if (filled != null)
|
||||
{
|
||||
event.result = filled;
|
||||
event.setFilledBucket(filled);
|
||||
event.setResult(Result.ALLOW);
|
||||
}
|
||||
}
|
||||
@@ -202,7 +206,7 @@ public class DynBucketTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TileEntity te = worldIn.getTileEntity(pos);
|
||||
if (!(te instanceof IFluidHandler))
|
||||
@@ -212,15 +216,14 @@ public class DynBucketTest
|
||||
IFluidHandler tank = (IFluidHandler) te;
|
||||
side = side.getOpposite();
|
||||
|
||||
ItemStack stack = playerIn.inventory.getCurrentItem();
|
||||
if (stack == null)
|
||||
if (heldItem == null)
|
||||
{
|
||||
sendText(playerIn, tank, side);
|
||||
return false;
|
||||
}
|
||||
|
||||
// do the thing with the tank and the buckets
|
||||
if (FluidUtil.interactWithTank(stack, playerIn, tank, side))
|
||||
if (FluidUtil.interactWithTank(heldItem, playerIn, tank, side))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -230,7 +233,7 @@ public class DynBucketTest
|
||||
}
|
||||
|
||||
// prevent interaction of the item if it's a fluidcontainer. Prevents placing liquids when interacting with the tank
|
||||
return FluidContainerRegistry.isFilledContainer(stack) || stack.getItem() instanceof IFluidContainerItem;
|
||||
return FluidContainerRegistry.isFilledContainer(heldItem) || heldItem.getItem() instanceof IFluidContainerItem;
|
||||
}
|
||||
|
||||
private void sendText(EntityPlayer player, IFluidHandler tank, EnumFacing side)
|
||||
@@ -259,7 +262,8 @@ public class DynBucketTest
|
||||
{
|
||||
int filled = tank.fill(resource, doFill);
|
||||
if(doFill && filled > 0) {
|
||||
worldObj.markBlockForUpdate(pos);
|
||||
IBlockState state = worldObj.getBlockState(pos);
|
||||
worldObj.func_184138_a(pos, state, state, 8); // TODO check flag
|
||||
}
|
||||
return filled;
|
||||
}
|
||||
@@ -276,7 +280,8 @@ public class DynBucketTest
|
||||
{
|
||||
FluidStack drained = tank.drain(maxDrain, doDrain);
|
||||
if(doDrain && drained != null) {
|
||||
worldObj.markBlockForUpdate(pos);
|
||||
IBlockState state = worldObj.getBlockState(pos);
|
||||
worldObj.func_184138_a(pos, state, state, 8); // TODO check flag
|
||||
}
|
||||
return drained;
|
||||
}
|
||||
@@ -315,7 +320,7 @@ public class DynBucketTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
public Packet<?> getDescriptionPacket() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
return new SPacketUpdateTileEntity(this.getPos(), this.getBlockMetadata(), tag);
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.minecraftforge.debug;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
@@ -125,10 +126,10 @@ public class ItemTileDebug
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() { return false; }
|
||||
public boolean isOpaqueCube(IBlockState state) { return false; }
|
||||
|
||||
@Override
|
||||
public boolean isFullCube() { return false; }
|
||||
public boolean isFullCube(IBlockState state) { return false; }
|
||||
|
||||
@Override
|
||||
public boolean isVisuallyOpaque() { return false; }
|
||||
|
||||
@@ -1,225 +0,0 @@
|
||||
|
||||
package net.minecraftforge.debug;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockModelShapes;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.IFlexibleBakedModel;
|
||||
import net.minecraftforge.client.model.ISmartBlockModel;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
@SuppressWarnings( "deprecation" )
|
||||
@Mod( modid = "LayerBreakingTest", name = "LayerBreakingTest", version = "0.0.0" )
|
||||
public class LayerBreakingTest
|
||||
{
|
||||
public static final boolean ENABLE = true;
|
||||
public static TestBlock testBlock;
|
||||
|
||||
class TestBakedModel implements IFlexibleBakedModel
|
||||
{
|
||||
TextureAtlasSprite texture;
|
||||
List<BakedQuad> list = new ArrayList<BakedQuad>();
|
||||
|
||||
private int[] vertexToInts(float x, float y, float z, int color, TextureAtlasSprite texture, int u, int v)
|
||||
{
|
||||
return new int[] { Float.floatToRawIntBits(x), Float.floatToRawIntBits(y), Float.floatToRawIntBits(z), color, Float.floatToRawIntBits(texture.getInterpolatedU(u)), Float.floatToRawIntBits(texture.getInterpolatedV(v)), 0 };
|
||||
}
|
||||
|
||||
public TestBakedModel(TextureAtlasSprite sprite, boolean top)
|
||||
{
|
||||
texture = sprite;
|
||||
if (top)
|
||||
{
|
||||
list.add(new BakedQuad(Ints.concat(vertexToInts(0.5f, 1.0f, 0, -1, texture, 8, 0), vertexToInts(0.5f, 1.0f, 1, -1, texture, 8, 16), vertexToInts(1, 1.0f, 1, -1, texture, 16, 16), vertexToInts(1, 1.0f, 0, -1, texture, 16, 0)), -1, EnumFacing.UP));
|
||||
}
|
||||
else
|
||||
{
|
||||
list.add(new BakedQuad(Ints.concat(vertexToInts(0, 1.0f, 0, -1, texture, 0, 0), vertexToInts(0, 1.0f, 1, -1, texture, 0, 16), vertexToInts(0.5f, 1.0f, 1, -1, texture, 8, 16), vertexToInts(0.5f, 1.0f, 0, -1, texture, 8, 0)), -1, EnumFacing.DOWN));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getFaceQuads(EnumFacing side)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getGeneralQuads()
|
||||
{
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexFormat getFormat()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
class TestBlock extends Block
|
||||
{
|
||||
protected TestBlock()
|
||||
{
|
||||
super(Material.glass);
|
||||
setHardness(7);
|
||||
setCreativeTab(CreativeTabs.tabBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isFullCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInLayer(BlockRenderLayer layer)
|
||||
{
|
||||
return layer == BlockRenderLayer.SOLID || layer == BlockRenderLayer.TRANSLUCENT;
|
||||
}
|
||||
};
|
||||
|
||||
class SmartModel implements IBakedModel, ISmartBlockModel
|
||||
{
|
||||
IFlexibleBakedModel solid;
|
||||
IFlexibleBakedModel translucent;
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getFaceQuads(EnumFacing p_177551_1_)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getGeneralQuads()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleBlockState(IBlockState state)
|
||||
{
|
||||
if (solid == null)
|
||||
{
|
||||
BlockModelShapes models = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
|
||||
translucent = new TestBakedModel(models.getModelForState(Blocks.stained_glass.getStateFromMeta(3)).getParticleTexture(), true);
|
||||
solid = new TestBakedModel(models.getModelForState(Blocks.cobblestone.getDefaultState()).getParticleTexture(), false);
|
||||
}
|
||||
|
||||
if (net.minecraftforge.client.MinecraftForgeClient.getRenderLayer() == BlockRenderLayer.SOLID)
|
||||
{
|
||||
return solid;
|
||||
}
|
||||
else
|
||||
{
|
||||
return translucent;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@SubscribeEvent
|
||||
public void onModelBakeEvent(ModelBakeEvent event)
|
||||
{
|
||||
event.modelRegistry.putObject(new ModelResourceLocation("layerbreakingtest:layer_breaking_test"), new SmartModel());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
if (ENABLE && event.getSide() == Side.CLIENT)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
GameRegistry.registerBlock(testBlock = new TestBlock(), "layer_breaking_test");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,21 +8,24 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
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.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
@@ -93,15 +96,15 @@ public class ModelAnimationDebug
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() { return false; }
|
||||
public boolean isOpaqueCube(IBlockState state) { return false; }
|
||||
|
||||
@Override
|
||||
public boolean isFullCube() { return false; }
|
||||
public boolean isFullCube(IBlockState state) { return false; }
|
||||
|
||||
@Override
|
||||
public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||
{
|
||||
return this.getDefaultState().withProperty(FACING, BlockPistonBase.getFacingFromEntity(world, pos, placer));
|
||||
return this.getDefaultState().withProperty(FACING, BlockPistonBase.func_185647_a(pos, placer));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,7 +143,7 @@ public class ModelAnimationDebug
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if(world.isRemote)
|
||||
{
|
||||
@@ -209,13 +212,13 @@ public class ModelAnimationDebug
|
||||
"chamber", "blocks/redstone_block",
|
||||
"trunk", "blocks/end_stone"
|
||||
);
|
||||
if(base instanceof IRetexturableModel)
|
||||
if(base instanceof IRetexturableModel<?>)
|
||||
{
|
||||
base = ((IRetexturableModel)base).retexture(textures);
|
||||
base = ((IRetexturableModel<?>)base).retexture(textures);
|
||||
}
|
||||
if(ring instanceof IRetexturableModel)
|
||||
if(ring instanceof IRetexturableModel<?>)
|
||||
{
|
||||
ring = ((IRetexturableModel)ring).retexture(textures);
|
||||
ring = ((IRetexturableModel<?>)ring).retexture(textures);
|
||||
}
|
||||
IModel model = new MultiModel(
|
||||
new ResourceLocation(ModelAnimationDebug.MODID, "builtin/engine"),
|
||||
@@ -225,7 +228,7 @@ public class ModelAnimationDebug
|
||||
"base", Pair.<IModel, IModelState>of(base, TRSRTransformation.identity())
|
||||
)
|
||||
);
|
||||
return new RenderLiving<EntityChest>(manager, new AnimationModelBase<EntityChest>(model, new VertexLighterSmoothAo())
|
||||
return new RenderLiving<EntityChest>(manager, new AnimationModelBase<EntityChest>(model, new VertexLighterSmoothAo(Minecraft.getMinecraft().func_184125_al()))
|
||||
{
|
||||
@Override
|
||||
public void handleEvents(EntityChest chest, float time, Iterable<Event> pastEvents)
|
||||
@@ -362,11 +365,12 @@ public class ModelAnimationDebug
|
||||
return asm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataWatcherUpdate(int id)
|
||||
// FIXME update health
|
||||
/*@Override
|
||||
public void func_184206_a(DataParameter<?> key)
|
||||
{
|
||||
super.onDataWatcherUpdate(id);
|
||||
if(id == 6) // health
|
||||
super.func_184206_a(key);
|
||||
if(field_184632_c.equals(key)) // health
|
||||
{
|
||||
if(cycleLength == null)
|
||||
{
|
||||
@@ -374,7 +378,7 @@ public class ModelAnimationDebug
|
||||
}
|
||||
cycleLength.setValue(getHealth() / 5);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
protected void applyEntityAttributes()
|
||||
|
||||
@@ -1,37 +1,36 @@
|
||||
package net.minecraftforge.debug;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
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.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.ISmartBlockModel;
|
||||
import net.minecraftforge.client.model.ISmartItemModel;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
@@ -45,9 +44,9 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Mod(modid = ModelBakeEventDebug.MODID, version = ModelBakeEventDebug.VERSION)
|
||||
public class ModelBakeEventDebug
|
||||
{
|
||||
@@ -136,13 +135,13 @@ public class ModelBakeEventDebug
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() { return 3; }
|
||||
public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; }
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() { return false; }
|
||||
public boolean isOpaqueCube(IBlockState state) { return false; }
|
||||
|
||||
@Override
|
||||
public boolean isFullCube() { return false; }
|
||||
public boolean isFullCube(IBlockState state) { return false; }
|
||||
|
||||
@Override
|
||||
public boolean isVisuallyOpaque() { return false; }
|
||||
@@ -154,7 +153,7 @@ public class ModelBakeEventDebug
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if(te instanceof CustomTileEntity)
|
||||
@@ -210,30 +209,18 @@ public class ModelBakeEventDebug
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomModel implements IBakedModel, ISmartBlockModel, ISmartItemModel
|
||||
public static class CustomModel implements IBakedModel
|
||||
{
|
||||
private final TextureAtlasSprite base, overlay;
|
||||
//private boolean hasStateSet = false;
|
||||
private final IExtendedBlockState state;
|
||||
|
||||
public CustomModel(TextureAtlasSprite base, TextureAtlasSprite overlay)
|
||||
{
|
||||
this(base, overlay, null);
|
||||
}
|
||||
|
||||
public CustomModel(TextureAtlasSprite base, TextureAtlasSprite overlay, IExtendedBlockState state)
|
||||
{
|
||||
this.base = base;
|
||||
this.overlay = overlay;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getFaceQuads(EnumFacing side)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// TODO update to builder
|
||||
private int[] vertexToInts(float x, float y, float z, int color, TextureAtlasSprite texture, float u, float v)
|
||||
{
|
||||
return new int[] {
|
||||
@@ -258,12 +245,14 @@ public class ModelBakeEventDebug
|
||||
vertexToInts((float)v2.xCoord, (float)v2.yCoord, (float)v2.zCoord, -1, texture, 0, 16),
|
||||
vertexToInts((float)v3.xCoord, (float)v3.yCoord, (float)v3.zCoord, -1, texture, 16, 16),
|
||||
vertexToInts((float)v4.xCoord, (float)v4.yCoord, (float)v4.zCoord, -1, texture, 16, 0)
|
||||
), -1, side);
|
||||
), -1, side, texture, DefaultVertexFormats.BLOCK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getGeneralQuads()
|
||||
public List<BakedQuad> func_188616_a(IBlockState state, EnumFacing side, long rand)
|
||||
{
|
||||
if(side != null || !(state instanceof IExtendedBlockState)) return ImmutableList.of();
|
||||
IExtendedBlockState exState = (IExtendedBlockState)state;
|
||||
int len = cubeSize * 5 + 1;
|
||||
List<BakedQuad> ret = new ArrayList<BakedQuad>();
|
||||
for(EnumFacing f : EnumFacing.values())
|
||||
@@ -273,13 +262,10 @@ public class ModelBakeEventDebug
|
||||
{
|
||||
for(int j = 0; j < cubeSize; j++)
|
||||
{
|
||||
if(state != null)
|
||||
Integer value = exState.getValue(properties[f.ordinal()]);
|
||||
if(value != null && (value & (1 << (i * cubeSize + j))) != 0)
|
||||
{
|
||||
Integer value = state.getValue(properties[f.ordinal()]);
|
||||
if(value != null && (value & (1 << (i * cubeSize + j))) != 0)
|
||||
{
|
||||
ret.add(createSidedBakedQuad((float)(1 + i * 5) / len, (float)(5 + i * 5) / len, (float)(1 + j * 5) / len, (float)(5 + j * 5) / len, 1.0001f, overlay, f));
|
||||
}
|
||||
ret.add(createSidedBakedQuad((float)(1 + i * 5) / len, (float)(5 + i * 5) / len, (float)(1 + j * 5) / len, (float)(5 + j * 5) / len, 1.0001f, overlay, f));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,29 +280,16 @@ public class ModelBakeEventDebug
|
||||
public boolean isAmbientOcclusion() { return true; }
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer() { return false; }
|
||||
public boolean func_188618_c() { return false; }
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture() { return this.base; }
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
}
|
||||
public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; }
|
||||
|
||||
@Override
|
||||
public IBakedModel handleBlockState(IBlockState state)
|
||||
{
|
||||
return new CustomModel(base, overlay, (IExtendedBlockState)state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(ItemStack stack)
|
||||
{
|
||||
IExtendedBlockState itemState = ((IExtendedBlockState)CustomModelBlock.instance.getDefaultState()).withProperty(properties[1], (1 << (cubeSize * cubeSize)) - 1);
|
||||
return new CustomModel(base, overlay, itemState);
|
||||
}
|
||||
public ItemOverrideList func_188617_f() { return ItemOverrideList.field_188022_a; }
|
||||
}
|
||||
|
||||
private static Vec3d rotate(Vec3d vec, EnumFacing side)
|
||||
|
||||
@@ -26,11 +26,13 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
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.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -162,7 +164,7 @@ public class ModelLoaderRegistryDebug
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if(world.isRemote)
|
||||
{
|
||||
@@ -249,7 +251,7 @@ public class ModelLoaderRegistryDebug
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (world.getTileEntity(pos) == null) world.setTileEntity(pos, new OBJTesseractTileEntity());
|
||||
OBJTesseractTileEntity tileEntity = (OBJTesseractTileEntity) world.getTileEntity(pos);
|
||||
@@ -278,8 +280,9 @@ public class ModelLoaderRegistryDebug
|
||||
|
||||
if (world.isRemote)
|
||||
{
|
||||
OBJBakedModel objBaked = (OBJBakedModel) Minecraft.getMinecraft().getBlockRendererDispatcher().getModelFromBlockState(state, world, pos);
|
||||
objBaked.scheduleRebake(); //not necessarily needed for this specific case, but is available
|
||||
// wtf
|
||||
//OBJBakedModel objBaked = (OBJBakedModel) Minecraft.getMinecraft().getBlockRendererDispatcher().getModelFromBlockState(state, world, pos);
|
||||
//objBaked.scheduleRebake(); //not necessarily needed for this specific case, but is available
|
||||
}
|
||||
world.markBlockRangeForRenderUpdate(pos, pos);
|
||||
return false;
|
||||
@@ -428,13 +431,6 @@ public class ModelLoaderRegistryDebug
|
||||
return ((EnumFacing) state.getValue(FACING)).getIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IBlockState getStateForEntityRender(IBlockState state)
|
||||
{
|
||||
return this.getDefaultState().withProperty(FACING, EnumFacing.NORTH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateContainer createBlockState()
|
||||
{
|
||||
@@ -506,7 +502,7 @@ public class ModelLoaderRegistryDebug
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof OBJVertexColoring2TileEntity)
|
||||
{
|
||||
@@ -531,6 +527,7 @@ public class ModelLoaderRegistryDebug
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
FMLLog.info("%b", shouldIncrement);
|
||||
/*
|
||||
IBakedModel bakedModel = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelFromBlockState(this.worldObj.getBlockState(this.pos), this.worldObj, this.pos);
|
||||
if (bakedModel != null && bakedModel instanceof OBJBakedModel)
|
||||
{
|
||||
@@ -552,6 +549,7 @@ public class ModelLoaderRegistryDebug
|
||||
{
|
||||
FMLLog.info("incrementing");
|
||||
String name = materialNames.get(index);
|
||||
// no
|
||||
objBaked.getModel().getMatLib().changeMaterialColor(name, 0xFF000000);
|
||||
objBaked.scheduleRebake();
|
||||
index++;
|
||||
@@ -568,12 +566,13 @@ public class ModelLoaderRegistryDebug
|
||||
String name = materialNames.get(index);
|
||||
if (!name.equals(OBJModel.Material.WHITE_NAME))
|
||||
{
|
||||
// FIXME
|
||||
objBaked.getModel().getMatLib().changeMaterialColor(name, color);
|
||||
objBaked.scheduleRebake();
|
||||
}
|
||||
}
|
||||
this.worldObj.markBlockRangeForRenderUpdate(this.pos, this.pos);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.minecraftforge.debug;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -36,10 +37,10 @@ public class MultiLayerModelDebug
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() { return false; }
|
||||
public boolean isOpaqueCube(IBlockState state) { return false; }
|
||||
|
||||
@Override
|
||||
public boolean isFullCube() { return false; }
|
||||
public boolean isFullCube(IBlockState state) { return false; }
|
||||
|
||||
@Override
|
||||
public boolean canRenderInLayer(BlockRenderLayer layer)
|
||||
|
||||
@@ -20,7 +20,7 @@ public class FOVModifierTest {
|
||||
|
||||
@SubscribeEvent
|
||||
public void getFOVModifier(EntityViewRenderEvent.FOVModifier event) {
|
||||
if(event.block.getMaterial() == Material.water)
|
||||
if(event.getState().func_185904_a() == Material.water)
|
||||
event.setFOV(event.getFOV() / 60.0f * 50.0f);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user