mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-25 22:44:38 +00:00
Fix design blocks
This commit is contained in:
1 parent
7666e96542
commit
172afd0574
20 files changed
+626
-430
No files matched your search
@@ -1,8 +1,11 @@
|
||||
package binnie.core.block;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -17,8 +20,8 @@ public interface IMultipassBlock<K> {
|
||||
K getWorldKey(IBlockState state);
|
||||
|
||||
/**
|
||||
* pass -1 = particle Sprite
|
||||
* pass -1 and facing null = particle Sprite
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
TextureAtlasSprite getSprite(K key, int pass);
|
||||
TextureAtlasSprite getSprite(K key, @Nullable EnumFacing facing, int pass);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package binnie.core.block;
|
||||
|
||||
import binnie.core.network.packet.MessageMetadata;
|
||||
import binnie.core.network.packet.PacketMetadata;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -27,6 +28,11 @@ public class TileEntityMetadata extends TileEntity {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getUpdateTag() {
|
||||
return writeToNBT(new NBTTagCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbt) {
|
||||
@@ -36,12 +42,11 @@ public class TileEntityMetadata extends TileEntity {
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(final NBTTagCompound nbt) {
|
||||
NBTTagCompound nbt2 = super.writeToNBT(nbt);
|
||||
nbt2.setInteger("meta", this.meta);
|
||||
return nbt2;
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("meta", this.meta);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
|
||||
public int getTileMetadata() {
|
||||
return this.meta;
|
||||
}
|
||||
@@ -59,6 +64,10 @@ public class TileEntityMetadata extends TileEntity {
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
|
||||
super.onDataPacket(net, pkt);
|
||||
|
||||
if(pkt instanceof PacketMetadata){
|
||||
setTileMetadata(((PacketMetadata) pkt).getMetadata(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,18 +4,19 @@ import binnie.Constants;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class DefaultStateMapper extends StateMapperBase {
|
||||
|
||||
private String modelName;
|
||||
private ResourceLocation resourceLocation;
|
||||
|
||||
public DefaultStateMapper(String modelName) {
|
||||
this.modelName = modelName;
|
||||
public DefaultStateMapper(ResourceLocation resourceLocation) {
|
||||
this.resourceLocation = resourceLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
|
||||
return new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":" + modelName, "normal");
|
||||
return new ModelResourceLocation(resourceLocation, "normal");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,7 +7,9 @@ import forestry.core.models.baker.ModelBaker;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -32,12 +34,16 @@ public class ModelMutlipass<B extends Block & IMultipassBlock<K>, K> extends Mod
|
||||
@Override
|
||||
protected void bakeBlock(B block, K key, IModelBaker baker, boolean inventory) {
|
||||
for (int pass = 0; pass < block.getRenderPasses(); pass++) {
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, block.getSprite(key, pass), pass);
|
||||
TextureAtlasSprite[] sprites = new TextureAtlasSprite[6];
|
||||
for(EnumFacing facing : EnumFacing.VALUES){
|
||||
sprites[facing.ordinal()] = block.getSprite(key, facing, pass);
|
||||
}
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, sprites, pass);
|
||||
}
|
||||
|
||||
// Set the particle sprite
|
||||
//TODO: Adding a preaking sprite
|
||||
baker.setParticleSprite(block.getSprite(key, 0));
|
||||
baker.setParticleSprite(block.getSprite(key, null, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,4 +28,8 @@ public class PacketMetadata extends SPacketUpdateTileEntity {
|
||||
metadata = buf.readInt();
|
||||
}
|
||||
|
||||
public int getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user