mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-16 01:55:15 +00:00
IT WORKS
This commit is contained in:
1 parent
319bab35a0
commit
f4ea60ba2c
7 files changed
+66
-25
No files matched your search
@@ -9,6 +9,8 @@ Anyways, vanilla removed it from their method so we follow suit.
|
||||
* SubTileEntity's methods that are copied from block (onBlockadded, etc.) updated to match vanilla counterparts
|
||||
* Multiblock system reworked to use states and blockposes
|
||||
* Magnet blacklist still uses metas instead of states because they need to support the short maxvalue wildcard.
|
||||
* Now includes a way for addons to pass the Botania loader the models they want to use to render their subtile with
|
||||
* todo: possibly make the unlisted properties use the subtile string name instead of class. Will be much easier.
|
||||
|
||||
-- Other --
|
||||
* Most things left untouched to make patches from upstream easier
|
||||
|
||||
@@ -42,20 +42,6 @@ import java.util.Map;
|
||||
|
||||
public class SpecialFlowerModel implements IModelCustomData {
|
||||
|
||||
/**
|
||||
* Internal implementation
|
||||
**/
|
||||
// SpecialFlowerModel for when there are no models registered for a subtile
|
||||
public static final SpecialFlowerModel INSTANCE = new SpecialFlowerModel(ImmutableMap.<Optional<Class<? extends SubTileEntity>>, ModelResourceLocation>of());
|
||||
// Models registered from the externel API thus far
|
||||
private static final Map<Class<? extends SubTileEntity>, ModelResourceLocation> queuedModels = Maps.newHashMap();
|
||||
private final ImmutableMap<Optional<Class<? extends SubTileEntity>>, ModelResourceLocation> models;
|
||||
|
||||
|
||||
public SpecialFlowerModel(ImmutableMap<Optional<Class<? extends SubTileEntity>>, ModelResourceLocation> models) {
|
||||
this.models = models;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register your model for the given subtile class here.
|
||||
* Call this DURING PREINIT. Calling it anytime after models have already baked does not guarantee that your model will work.
|
||||
@@ -70,6 +56,21 @@ public class SpecialFlowerModel implements IModelCustomData {
|
||||
queuedModels.put(subTileClass, model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal implementation
|
||||
**/
|
||||
// SpecialFlowerModel for when there are no models registered for a subtile
|
||||
public static final SpecialFlowerModel INSTANCE = new SpecialFlowerModel(ImmutableMap.<Optional<Class<? extends SubTileEntity>>, ModelResourceLocation>of());
|
||||
// Models registered from the externel API thus far
|
||||
private static final Map<Class<? extends SubTileEntity>, ModelResourceLocation> queuedModels = Maps.newHashMap();
|
||||
|
||||
|
||||
private final ImmutableMap<Optional<Class<? extends SubTileEntity>>, ModelResourceLocation> models;
|
||||
|
||||
public SpecialFlowerModel(ImmutableMap<Optional<Class<? extends SubTileEntity>>, ModelResourceLocation> models) {
|
||||
this.models = models;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies() {
|
||||
return ImmutableList.<ResourceLocation>copyOf(models.values());
|
||||
@@ -125,8 +126,10 @@ public class SpecialFlowerModel implements IModelCustomData {
|
||||
|
||||
@Override
|
||||
public boolean accepts(ResourceLocation modelLocation) {
|
||||
return "botania_SPECIAL".equals(modelLocation.getResourceDomain())
|
||||
&& "specialFlower".equals(modelLocation.getResourcePath());
|
||||
return modelLocation.getResourceDomain().equals("botania_special") && (
|
||||
modelLocation.getResourcePath().equals("specialFlower") ||
|
||||
modelLocation.getResourcePath().equals("models/block/specialFlower") ||
|
||||
modelLocation.getResourcePath().equals("models/item/specialFlower"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,7 +157,8 @@ public class SpecialFlowerModel implements IModelCustomData {
|
||||
}
|
||||
|
||||
private void refreshBakedModels() {
|
||||
if (baseModel == null) {
|
||||
System.out.println("Refreshing");
|
||||
//if (baseModel == null) {
|
||||
ModelManager manager = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager();
|
||||
baseModel = getModel(manager, Optional.<Class<? extends SubTileEntity>>absent());
|
||||
|
||||
@@ -173,11 +177,11 @@ public class SpecialFlowerModel implements IModelCustomData {
|
||||
quadBuilder.put(Optional.of(side), buildQuads(Optional.of(side)));
|
||||
}
|
||||
quads = quadBuilder.build();
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
private IBakedModel getModel(ModelManager manager, Optional<Class<? extends SubTileEntity>> layer) {
|
||||
ModelResourceLocation loc = models.get(layer);
|
||||
private IBakedModel getModel(ModelManager manager, Optional<Class<? extends SubTileEntity>> optClazz) {
|
||||
ModelResourceLocation loc = models.get(optClazz);
|
||||
if (loc == null) {
|
||||
loc = new ModelResourceLocation("builtin/missing", "missing");
|
||||
}
|
||||
@@ -205,7 +209,7 @@ public class SpecialFlowerModel implements IModelCustomData {
|
||||
@Override
|
||||
public List<BakedQuad> getGeneralQuads() {
|
||||
refreshBakedModels();
|
||||
return quads.get(Optional.absent());
|
||||
return quads.get(Optional.<EnumFacing>absent());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -239,6 +243,7 @@ public class SpecialFlowerModel implements IModelCustomData {
|
||||
|
||||
@Override
|
||||
public IBakedModel handleBlockState(IBlockState state) {
|
||||
refreshBakedModels();
|
||||
IExtendedBlockState extendedState = ((IExtendedBlockState) state);
|
||||
Class<? extends SubTileEntity> clazz = extendedState.getValue(BotaniaStateProps.SUBTILE_CLASS);
|
||||
return bakedFlowerModels.get(clazz);
|
||||
|
||||
@@ -11,8 +11,10 @@ import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
import vazkii.botania.api.render.SpecialFlowerModel;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.api.state.enums.AltGrassVariant;
|
||||
import vazkii.botania.api.state.enums.LivingRockVariant;
|
||||
@@ -21,6 +23,7 @@ import vazkii.botania.api.state.enums.StorageVariant;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.ModFluffBlocks;
|
||||
import vazkii.botania.common.block.decor.slabs.BlockModSlab;
|
||||
import vazkii.botania.common.block.subtile.generating.SubTileDaybloom;
|
||||
import vazkii.botania.common.item.ItemGaiaHead;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
@@ -36,8 +39,11 @@ public final class ModelHandler {
|
||||
// In addition, many of the jsons currently use the vanilla format (simple and verified bug-free).
|
||||
// Once things settle down, we'll move to forge jsons, which will drastically cut down on the number of json files
|
||||
public static void registerModels() {
|
||||
ModelLoaderRegistry.registerLoader(SpecialFlowerModel.Loader.INSTANCE);
|
||||
OBJLoader.instance.addDomain(LibMisc.MOD_ID.toLowerCase(Locale.ROOT));
|
||||
|
||||
SpecialFlowerModel.register(SubTileDaybloom.class, new ModelResourceLocation("botania:daybloom"));
|
||||
|
||||
/** Custom statemappers **/
|
||||
registerStateMappers();
|
||||
|
||||
@@ -129,8 +135,7 @@ public final class ModelHandler {
|
||||
// Ignore redstone power state in some blocks
|
||||
ModelLoader.setCustomStateMapper(ModBlocks.starfield, (new StateMap.Builder()).ignore(BotaniaStateProps.POWERED).build());
|
||||
|
||||
// Ignore color in special flower, unstable cube, mana beacon, and petals (handled by color multiplier)
|
||||
ModelLoader.setCustomStateMapper(ModBlocks.specialFlower, (new StateMap.Builder()).ignore(BotaniaStateProps.COLOR).build());
|
||||
// Ignore color in unstable cube, mana beacon, and petals (handled by color multiplier)
|
||||
ModelLoader.setCustomStateMapper(ModBlocks.unstableBlock, (new StateMap.Builder()).ignore(BotaniaStateProps.COLOR).build());
|
||||
ModelLoader.setCustomStateMapper(ModBlocks.manaBeacon, (new StateMap.Builder()).ignore(BotaniaStateProps.COLOR).build());
|
||||
ModelLoader.setCustomStateMapper(ModBlocks.petalBlock, (new StateMap.Builder()).ignore(BotaniaStateProps.COLOR).build());
|
||||
|
||||
@@ -182,7 +182,6 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
super.preInit(event);
|
||||
|
||||
ModelLoaderRegistry.registerLoader(SpecialFlowerModel.Loader.INSTANCE);
|
||||
ModelHandler.registerModels();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.block.statemap.DefaultStateMapper;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -35,9 +37,14 @@ import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
@@ -121,6 +128,18 @@ public class BlockSpecialFlower extends BlockFlower implements ITileEntityProvid
|
||||
.withProperty(BotaniaStateProps.SUBTILE_CLASS, SubTileDaybloom.class)
|
||||
.withProperty(BotaniaStateProps.COLOR, EnumDyeColor.WHITE).withProperty(type, EnumFlowerType.POPPY)
|
||||
);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onModelBake(ModelBakeEvent evt) {
|
||||
evt.modelManager.getBlockModelShapes().registerBlockWithStateMapper(this, new DefaultStateMapper() {
|
||||
@Override
|
||||
public ModelResourceLocation getModelResourceLocation(IBlockState state) {
|
||||
return new ModelResourceLocation("botania:specialFlower");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"forge_marker": 1,
|
||||
"variants": {
|
||||
"normal": [{
|
||||
"model": "minecraft:cross",
|
||||
"textures": {
|
||||
"cross": "botania:blocks/daybloom"
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"model": "botania_SPECIAL:specialFlower",
|
||||
"model": "botania_special:specialFlower",
|
||||
"transform": "forge:default-block"
|
||||
},
|
||||
"variants": {
|
||||
|
||||
Reference in new issue
Block a user