mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 20:22:33 +00:00
Fix item models, finally done
This commit is contained in:
1 parent
898112885d
commit
4a4b11c44a
2 files changed
+33
-1
No files matched your search
@@ -17,6 +17,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import vazkii.botania.client.model.FloatingFlowerModel;
|
||||
import vazkii.botania.client.model.GunModel;
|
||||
import vazkii.botania.client.model.LexiconModel;
|
||||
import vazkii.botania.client.model.PlatformModel;
|
||||
@@ -25,6 +26,8 @@ import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara;
|
||||
import vazkii.botania.common.item.relic.ItemKingKey;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static vazkii.botania.common.lib.ResourceLocationHelper.prefix;
|
||||
|
||||
public class MiscellaneousIcons {
|
||||
@@ -77,6 +80,15 @@ public class MiscellaneousIcons {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onModelBake(ModelBakeEvent evt) {
|
||||
// Floating flower item models
|
||||
for (Map.Entry<ResourceLocation, IBakedModel> e : evt.getModelRegistry().entrySet()) {
|
||||
if (e.getValue() instanceof FloatingFlowerModel.Baked) {
|
||||
ResourceLocation stripVariant = new ResourceLocation(e.getKey().getNamespace(), e.getKey().getPath());
|
||||
ModelResourceLocation itemPath = new ModelResourceLocation(stripVariant, "inventory");
|
||||
evt.getModelRegistry().put(itemPath, e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
// Platforms
|
||||
ModelResourceLocation abstruseName = new ModelResourceLocation("botania:abstruse_platform", "");
|
||||
IBakedModel abstruse = evt.getModelRegistry().get(abstruseName);
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.texture.ISprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
@@ -21,12 +22,14 @@ import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import vazkii.botania.api.BotaniaAPIClient;
|
||||
import vazkii.botania.api.item.IFloatingFlower;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -103,12 +106,14 @@ public class FloatingFlowerModel implements IUnbakedModel {
|
||||
return new Baked(bakedFlower, bakedIslands);
|
||||
}
|
||||
|
||||
private static class Baked extends BakedModelWrapper<IBakedModel> {
|
||||
public static class Baked extends BakedModelWrapper<IBakedModel> {
|
||||
private final Map<IFloatingFlower.IslandType, IBakedModel> islands;
|
||||
private final Map<IFloatingFlower.IslandType, List<BakedQuad>> genQuads = new HashMap<>();
|
||||
private final Map<IFloatingFlower.IslandType, Map<Direction, List<BakedQuad>>> faceQuads = new HashMap<>();
|
||||
|
||||
Baked(IBakedModel flower, Map<IFloatingFlower.IslandType, IBakedModel> islands) {
|
||||
super(flower);
|
||||
this.islands = islands;
|
||||
Random rand = new Random();
|
||||
for (Map.Entry<IFloatingFlower.IslandType, IBakedModel> e : islands.entrySet()) {
|
||||
rand.setSeed(42);
|
||||
@@ -129,6 +134,13 @@ public class FloatingFlowerModel implements IUnbakedModel {
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand) {
|
||||
// Default to GRASS island
|
||||
return getQuads(state, side, rand, EmptyModelData.INSTANCE);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
|
||||
@@ -143,6 +155,14 @@ public class FloatingFlowerModel implements IUnbakedModel {
|
||||
return faceQuads.get(type).get(side);
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(@Nonnull ItemCameraTransforms.TransformType cameraTransformType) {
|
||||
// Use the item transforms from the islands since it looks better
|
||||
Pair<? extends IBakedModel, Matrix4f> p = this.islands.values().iterator().next().handlePerspective(cameraTransformType);
|
||||
return Pair.of(this, p.getRight());
|
||||
}
|
||||
}
|
||||
|
||||
public enum Loader implements ICustomModelLoader {
|
||||
|
||||
Reference in new issue
Block a user