mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-18 19:39:37 +00:00
Start to work on ceramic blocks
This commit is contained in:
1 parent
4b6e3e5424
commit
9e68539431
28 files changed
+1009
-661
No files matched your search
@@ -17,6 +17,7 @@ import binnie.core.mod.config.ConfigurationMain;
|
||||
import binnie.core.mod.config.ConfigurationMods;
|
||||
import binnie.core.mod.parser.FieldParser;
|
||||
import binnie.core.mod.parser.ItemParser;
|
||||
import binnie.core.models.ModelManager;
|
||||
import binnie.core.network.BinnieCorePacketID;
|
||||
import binnie.core.network.BinniePacketHandler;
|
||||
import binnie.core.network.IPacketID;
|
||||
@@ -29,6 +30,7 @@ import forestry.plugins.PluginManager;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
@@ -172,6 +174,12 @@ public final class BinnieCore extends AbstractMod {
|
||||
// }
|
||||
Binnie.Resource.registerIcons();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleModelBake(ModelBakeEvent event) {
|
||||
ModelManager.registerCustomModels(event);
|
||||
}
|
||||
|
||||
public static class PacketHandler extends BinniePacketHandler {
|
||||
public PacketHandler() {
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package binnie.core.block;
|
||||
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.core.models.ModelBlockCached;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ModelMutlipass<B extends Block & IMultipassBlock<K>, K> extends ModelBlockCached<B, K> {
|
||||
|
||||
public ModelMutlipass(Class<B> blockClass) {
|
||||
super(blockClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected K getInventoryKey(ItemStack stack) {
|
||||
return ((B) Block.getBlockFromItem(stack.getItem())).getInventoryKey(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected K getWorldKey(IBlockState state) {
|
||||
return ((B) state.getBlock()).getWorldKey(state);
|
||||
}
|
||||
|
||||
@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), 0);
|
||||
}
|
||||
|
||||
// Set the particle sprite
|
||||
baker.setParticleSprite(block.getSprite(key, -1));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -50,8 +50,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package binnie.core.models;
|
||||
|
||||
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;
|
||||
|
||||
public class DefaultStateMapper extends StateMapperBase {
|
||||
|
||||
@Override
|
||||
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
|
||||
return new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":ceramicBrick", "normal");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package binnie.core.models;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.ISpriteRegister;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.core.blocks.IColoredBlock;
|
||||
import forestry.core.items.IColoredItem;
|
||||
@@ -42,13 +45,14 @@ public class ModelManager implements IModelManager {
|
||||
|
||||
private final String modID;
|
||||
|
||||
private final List<BlockModelEntry> customBlockModels = new ArrayList<>();
|
||||
private final List<ModelEntry> customModels = new ArrayList<>();
|
||||
private final static List<BlockModelEntry> customBlockModels = new ArrayList<>();
|
||||
private final static List<ModelEntry> customModels = new ArrayList<>();
|
||||
|
||||
private final List<IItemModelRegister> itemModelRegisters = new ArrayList<>();
|
||||
private final List<IStateMapperRegister> stateMapperRegisters = new ArrayList<>();
|
||||
private final List<IColoredBlock> blockColorList = new ArrayList<>();
|
||||
private final List<IColoredItem> itemColorList = new ArrayList<>();
|
||||
private final static List<ISpriteRegister> spriteRegister = new ArrayList<>();
|
||||
|
||||
private TRSRTransformation flipX = new TRSRTransformation(null, null, new Vector3f(-1, 1, 1), null);
|
||||
public final IModelState DEFAULT_BLOCK;
|
||||
@@ -149,6 +153,9 @@ public class ModelManager implements IModelManager {
|
||||
if (block instanceof IColoredBlock) {
|
||||
blockColorList.add((IColoredBlock) block);
|
||||
}
|
||||
if (block instanceof ISpriteRegister) {
|
||||
spriteRegister.add((ISpriteRegister) block);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -159,6 +166,9 @@ public class ModelManager implements IModelManager {
|
||||
if (item instanceof IColoredItem) {
|
||||
itemColorList.add((IColoredItem) item);
|
||||
}
|
||||
if (item instanceof ISpriteRegister) {
|
||||
spriteRegister.add((ISpriteRegister) item);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -180,6 +190,15 @@ public class ModelManager implements IModelManager {
|
||||
stateMapperRegister.registerStateMapper();
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void reloadSprites() {
|
||||
for (ISpriteRegister spriteRegister : spriteRegister) {
|
||||
if(spriteRegister != null){
|
||||
spriteRegister.registerSprites(ForestryAPI.textureManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerItemAndBlockColors() {
|
||||
@@ -236,7 +255,7 @@ public class ModelManager implements IModelManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void registerCustomModels(ModelBakeEvent event) {
|
||||
public static void registerCustomModels(ModelBakeEvent event) {
|
||||
IRegistry<ModelResourceLocation, IBakedModel> registry = event.getModelRegistry();
|
||||
for (final BlockModelEntry entry : customBlockModels) {
|
||||
registry.putObject(entry.blockModelLocation, entry.model);
|
||||
@@ -250,11 +269,11 @@ public class ModelManager implements IModelManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void registerCustomBlockModel(@Nonnull BlockModelEntry index) {
|
||||
public static void registerCustomBlockModel(@Nonnull BlockModelEntry index) {
|
||||
customBlockModels.add(index);
|
||||
}
|
||||
|
||||
public void registerCustomModel(@Nonnull ModelEntry index) {
|
||||
public static void registerCustomModel(@Nonnull ModelEntry index) {
|
||||
customModels.add(index);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package binnie.core.models;
|
||||
|
||||
import binnie.core.block.IMultipassBlock;
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.core.models.ModelBlockCached;
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelMutlipass<B extends Block & IMultipassBlock<K>, K> extends ModelBlockCached<B, K> {
|
||||
|
||||
public ModelMutlipass(Class<B> blockClass) {
|
||||
super(blockClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected K getInventoryKey(ItemStack stack) {
|
||||
return ((B) Block.getBlockFromItem(stack.getItem())).getInventoryKey(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected K getWorldKey(IBlockState state) {
|
||||
return ((B) state.getBlock()).getWorldKey(state);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
// Set the particle sprite
|
||||
//TODO: Adding a preaking sprite
|
||||
baker.setParticleSprite(block.getSprite(key, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IBakedModel bakeModel(ItemStack stack, World world, K key) {
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IModelBaker baker = new ModelBaker();
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
if (!blockClass.isInstance(block)) {
|
||||
return null;
|
||||
}
|
||||
B bBlock = blockClass.cast(block);
|
||||
|
||||
baker.setRenderBounds(Block.FULL_BLOCK_AABB);
|
||||
bakeBlock(bBlock, key, baker, true);
|
||||
|
||||
return itemModel = baker.bakeModel(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -106,6 +106,11 @@ public class BinnieProxy extends BinnieModProxy implements IBinnieProxy {
|
||||
|
||||
@Override
|
||||
public void registerTileEntity(final Class<? extends TileEntity> tile, final String id, @Nullable final Object renderer) {
|
||||
registerTileEntity(tile, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTileEntity(final Class<? extends TileEntity> tile, final String id) {
|
||||
GameRegistry.registerTileEntity(tile, id);
|
||||
}
|
||||
|
||||
@@ -156,6 +161,9 @@ public class BinnieProxy extends BinnieModProxy implements IBinnieProxy {
|
||||
@Override
|
||||
public void bindTexture(final ResourceLocation location) {
|
||||
}
|
||||
|
||||
public void reloadSprites(){
|
||||
}
|
||||
|
||||
public boolean isShiftDown() {
|
||||
return false;
|
||||
|
||||
@@ -51,6 +51,11 @@ public final class BinnieProxyClient extends BinnieProxy implements IBinnieProxy
|
||||
public void registerModels() {
|
||||
getModelManager().registerModels();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadSprites() {
|
||||
ModelManager.reloadSprites();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItemAndBlockColors() {
|
||||
|
||||
@@ -42,6 +42,8 @@ public interface IBinnieProxy extends IProxyCore {
|
||||
Object createObject(final String p0);
|
||||
|
||||
void registerTileEntity(final Class<? extends TileEntity> tile, final String id, @Nullable final Object renderer);
|
||||
|
||||
void registerTileEntity(final Class<? extends TileEntity> tile, final String id);
|
||||
|
||||
void createPipe(final Item p0);
|
||||
|
||||
|
||||
@@ -17,4 +17,5 @@ public interface IProxyCore extends IInitializable {
|
||||
|
||||
public void registerItemAndBlockColors();
|
||||
|
||||
|
||||
}
|
||||
@@ -37,6 +37,7 @@ public class ManagerResource {
|
||||
for (final BinnieIcon icon : this.icons) {
|
||||
BinnieCore.proxy.registerIcon(icon.getResourceLocation());
|
||||
}
|
||||
BinnieCore.proxy.reloadSprites();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user