mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 11:19:19 +00:00
Updates to internal handler and icons
This commit is contained in:
1 parent
a4a77fb20f
commit
972943a9ac
7 files changed
+70
-66
No files matched your search
@@ -1,11 +1,13 @@
|
||||
package vazkii.botania.api;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import vazkii.botania.api.subtile.SubTileEntity;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -14,15 +16,14 @@ import java.util.Map;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public final class BotaniaAPIClient {
|
||||
|
||||
public static final Map<String, ModelResourceLocation> queuedBlockModels = Maps.newHashMap();
|
||||
public static final Map<String, ModelResourceLocation> queuedItemModels = Maps.newHashMap();
|
||||
private static final Map<String, ModelResourceLocation> queuedBlockModels = Maps.newHashMap();
|
||||
private static final Map<String, ModelResourceLocation> queuedItemModels = Maps.newHashMap();
|
||||
|
||||
/**
|
||||
* Register your model for the given subtile class here.
|
||||
* Call this DURING PREINIT. Calling it anytime after blockModels have already baked does not guarantee that your model will work.
|
||||
* Your model json must specify key "tintindex" in all the faces it wants tint applied.
|
||||
* Tint is applied whenever a player recolors the flower using floral dye
|
||||
* todo 1.8.8 move this elsewhere or otherwise make it fit better with the rest of the subtile registration process
|
||||
*
|
||||
* @param subTileName The String ID of the subtile
|
||||
* @param model A path to a blockstate json and variant to be used for this subtile
|
||||
@@ -38,7 +39,6 @@ public final class BotaniaAPIClient {
|
||||
* Call this DURING PREINIT. Calling it anytime after blockModels have already baked does not guarantee that your model will work.
|
||||
* Your model json must specify key "tintindex" in all the faces it wants tint applied.
|
||||
* Tint is applied whenever a player recolors the flower using floral dye
|
||||
* todo 1.8.8 move this elsewhere or otherwise make it fit better with the rest of the subtile registration process
|
||||
*
|
||||
* @param subTileName The String ID of the subtile
|
||||
* @param model A path to a blockstate json and variant to be used the block. The item model will be drawn from the same blockstate json, from variant "inventory"
|
||||
@@ -56,6 +56,20 @@ public final class BotaniaAPIClient {
|
||||
registerSubtileModel(BotaniaAPI.getSubTileStringMapping(clazz), model, itemModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An immutable view of the registered subtile block model map
|
||||
*/
|
||||
public static Map<String, ModelResourceLocation> getRegisteredSubtileBlockModels() {
|
||||
return Collections.unmodifiableMap(queuedBlockModels);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An immutable view of the registered subtile item model map
|
||||
*/
|
||||
public static Map<String, ModelResourceLocation> getRegisteredSubtileItemModels() {
|
||||
return Collections.unmodifiableMap(queuedItemModels);
|
||||
}
|
||||
|
||||
private BotaniaAPIClient() {}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import java.util.List;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -27,6 +28,8 @@ import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import vazkii.botania.api.boss.IBotaniaBoss;
|
||||
import vazkii.botania.api.lexicon.LexiconPage;
|
||||
import vazkii.botania.api.lexicon.multiblock.MultiblockSet;
|
||||
@@ -134,13 +137,13 @@ public class DummyMethodHandler implements IInternalMethodHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getSubTileIconForName(String name) {
|
||||
return null; //todo 1.8 return Blocks.red_flower.getIcon(0, 0);
|
||||
public ModelResourceLocation getSubTileBlockModelForName(String name) {
|
||||
return new ModelResourceLocation("builtin/missing", "missing");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBasicSignatureIcons(String name, TextureMap map) {
|
||||
// NO-OP
|
||||
public ModelResourceLocation getSubTileItemModelForName(String name) {
|
||||
return new ModelResourceLocation("builtin/missing", "missing");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.List;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -85,10 +86,11 @@ public interface IInternalMethodHandler {
|
||||
|
||||
public String getStackSubTileKey(ItemStack stack);
|
||||
|
||||
// todo 1.8 evaluate need for these two
|
||||
public TextureAtlasSprite getSubTileIconForName(String name);
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ModelResourceLocation getSubTileBlockModelForName(String name);
|
||||
|
||||
public void registerBasicSignatureIcons(String name, TextureMap map);
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ModelResourceLocation getSubTileItemModelForName(String name);
|
||||
|
||||
public boolean shouldForceCheck();
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -94,11 +95,19 @@ public class SubTileEntity {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the icon for this SubTileEntity, this is a block icon.
|
||||
* Gets the block model path for this subtile
|
||||
*/
|
||||
@SideOnly(Side.CLIENT) // todo 1.8 reevaluate need
|
||||
public TextureAtlasSprite getIcon() {
|
||||
return BotaniaAPI.internalHandler.getSubTileIconForName(getUnlocalizedName());
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ModelResourceLocation getBlockModel() {
|
||||
return BotaniaAPI.internalHandler.getSubTileBlockModelForName(getUnlocalizedName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item model path for this subtile
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ModelResourceLocation getItemModel() {
|
||||
return BotaniaAPI.internalHandler.getSubTileItemModelForName(getUnlocalizedName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -96,6 +96,7 @@ public class FloatingFlowerModel implements ISmartItemModel, ISmartBlockModel, I
|
||||
return getModel(islandType, identifier);
|
||||
}
|
||||
|
||||
// Get the model for this islandtype + flower type combination. If it's not cached already, generate it.
|
||||
private CompositeBakedModel getModel(IFloatingFlower.IslandType islandType, String identifier) {
|
||||
ModelManager modelManager = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager();
|
||||
|
||||
@@ -177,59 +178,35 @@ public class FloatingFlowerModel implements ISmartItemModel, ISmartBlockModel, I
|
||||
genQuads = genBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getGeneralQuads() {
|
||||
// Forward all to flower model
|
||||
@Override public List<BakedQuad> getGeneralQuads() {
|
||||
return genQuads;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getFaceQuads(EnumFacing p_177551_1_) { return ImmutableList.of(); }
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion() {
|
||||
@Override public List<BakedQuad> getFaceQuads(EnumFacing p_177551_1_) { return ImmutableList.of(); }
|
||||
@Override public boolean isAmbientOcclusion() {
|
||||
return base.isAmbientOcclusion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d() {
|
||||
@Override public boolean isGui3d() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer() {
|
||||
@Override public boolean isBuiltInRenderer() {
|
||||
return base.isBuiltInRenderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
@Override public TextureAtlasSprite getParticleTexture() {
|
||||
return base.getParticleTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms() {
|
||||
@Override public ItemCameraTransforms getItemCameraTransforms() {
|
||||
return base.getItemCameraTransforms();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getFaceQuads(EnumFacing p_177551_1_) { return ImmutableList.of(); }
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getGeneralQuads() { return ImmutableList.of(); }
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion() { return false; }
|
||||
|
||||
@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; }
|
||||
// Dummy results
|
||||
@Override public List<BakedQuad> getFaceQuads(EnumFacing p_177551_1_) { return ImmutableList.of(); }
|
||||
@Override public List<BakedQuad> getGeneralQuads() { return ImmutableList.of(); }
|
||||
@Override public boolean isAmbientOcclusion() { return false; }
|
||||
@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; }
|
||||
|
||||
}
|
||||
@@ -108,10 +108,10 @@ public class SpecialFlowerModel implements IModelCustomData {
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, ModelResourceLocation> e : BotaniaAPIClient.queuedBlockModels.entrySet()) {
|
||||
for (Map.Entry<String, ModelResourceLocation> e : BotaniaAPIClient.getRegisteredSubtileBlockModels().entrySet()) {
|
||||
blockBuilder.put(Optional.of(e.getKey()), e.getValue());
|
||||
}
|
||||
for (Map.Entry<String, ModelResourceLocation> e : BotaniaAPIClient.queuedItemModels.entrySet()) {
|
||||
for (Map.Entry<String, ModelResourceLocation> e : BotaniaAPIClient.getRegisteredSubtileItemModels().entrySet()) {
|
||||
itemBuilder.put(Optional.of(e.getKey()), e.getValue());
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -30,6 +31,8 @@ import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import vazkii.botania.api.BotaniaAPIClient;
|
||||
import vazkii.botania.api.boss.IBotaniaBoss;
|
||||
import vazkii.botania.api.internal.DummyMethodHandler;
|
||||
import vazkii.botania.api.internal.IManaNetwork;
|
||||
@@ -46,6 +49,7 @@ import vazkii.botania.api.subtile.SubTileGenerating;
|
||||
import vazkii.botania.client.core.handler.BossBarHandler;
|
||||
import vazkii.botania.client.core.handler.HUDHandler;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.client.render.SpecialFlowerModel;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.BlockModFlower;
|
||||
import vazkii.botania.common.block.BlockSpecialFlower;
|
||||
@@ -98,18 +102,13 @@ public class InternalMethodHandler extends DummyMethodHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getSubTileIconForName(String name) {
|
||||
// IIcon icon = (ConfigHandler.altFlowerTextures ? BlockSpecialFlower.iconsAlt : BlockSpecialFlower.icons).get(name);
|
||||
// return icon == null ? Blocks.red_flower.getIcon(0, 0) : icon; todo 1.8
|
||||
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:red_flower");
|
||||
public ModelResourceLocation getSubTileBlockModelForName(String name) {
|
||||
return BotaniaAPIClient.getRegisteredSubtileBlockModels().get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBasicSignatureIcons(String name, TextureMap map) {
|
||||
// IIcon normal = IconHelper.forName(register, name); todo 1.8
|
||||
// IIcon alt = IconHelper.forName(register, BlockModFlower.ALT_DIR + "/" + name);
|
||||
// BlockSpecialFlower.icons.put(name, normal);
|
||||
// BlockSpecialFlower.iconsAlt.put(name, alt == null ? normal : alt);
|
||||
public ModelResourceLocation getSubTileItemModelForName(String name) {
|
||||
return BotaniaAPIClient.getRegisteredSubtileItemModels().get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user