Refactored item registering and rendering

- Item holders are now initialized with suppliers
- Reduced redundancies with defining and registering custom item rendering
- Removed the Gardens module
- Fixed some colors in the existing custom item models
This commit is contained in:
simibubi 2020-02-03 16:47:58 +01:00
parent 0099fe9b0d
commit b5b1a995d7
38 changed files with 500 additions and 512 deletions

View file

@ -208,8 +208,6 @@ public enum AllBlocks {
SYMMETRY_CROSSPLANE(new CrossPlaneSymmetryBlock()),
SYMMETRY_TRIPLEPLANE(new TriplePlaneSymmetryBlock()),
WINDOW_IN_A_BLOCK(new WindowInABlockBlock()),
__GARDENS__(),
COCOA_LOG(new CocoaLogBlock()),
__PALETTES__(),
@ -343,7 +341,7 @@ public enum AllBlocks {
private static void registerAsItem(IForgeRegistry<Item> registry, Block blockIn) {
BlockItem blockItem = null;
net.minecraft.item.Item.Properties standardItemProperties = AllItems.standardItemProperties();
Item.Properties standardItemProperties = AllItems.includeInItemGroup();
if (blockIn instanceof IHaveCustomBlockItem)
blockItem = ((IHaveCustomBlockItem) blockIn).getCustomItem(standardItemProperties);

View file

@ -1,24 +1,22 @@
package com.simibubi.create;
import java.util.function.Function;
import com.simibubi.create.foundation.item.IHaveCustomItemModel;
import com.simibubi.create.foundation.item.IItemWithColorHandler;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.modules.IModule;
import com.simibubi.create.modules.contraptions.GogglesItem;
import com.simibubi.create.modules.contraptions.WrenchItem;
import com.simibubi.create.modules.contraptions.WrenchItemRenderer;
import com.simibubi.create.modules.contraptions.relays.belt.BeltConnectorItem;
import com.simibubi.create.modules.contraptions.relays.gearbox.VerticalGearboxItem;
import com.simibubi.create.modules.curiosities.ChromaticCompoundCubeItem;
import com.simibubi.create.modules.curiosities.RefinedRadianceItem;
import com.simibubi.create.modules.curiosities.ShadowSteelItem;
import com.simibubi.create.modules.curiosities.blockzapper.BlockzapperItem;
import com.simibubi.create.modules.curiosities.blockzapper.BlockzapperItemRenderer;
import com.simibubi.create.modules.curiosities.deforester.DeforesterItem;
import com.simibubi.create.modules.curiosities.deforester.DeforesterItemRenderer;
import com.simibubi.create.modules.curiosities.symmetry.SymmetryWandItem;
import com.simibubi.create.modules.curiosities.symmetry.client.SymmetryWandItemRenderer;
import com.simibubi.create.modules.curiosities.tools.SandPaperItem;
import com.simibubi.create.modules.curiosities.tools.SandPaperItemRenderer;
import com.simibubi.create.modules.gardens.TreeFertilizerItem;
import com.simibubi.create.modules.logistics.item.filter.FilterItem;
import com.simibubi.create.modules.schematics.item.SchematicAndQuillItem;
@ -41,71 +39,63 @@ import net.minecraftforge.registries.IForgeRegistry;
@EventBusSubscriber(value = Dist.CLIENT, bus = Bus.MOD)
public enum AllItems {
__MATERIALS__(),
COPPER_NUGGET(ingredient()),
ZINC_NUGGET(ingredient()),
BRASS_NUGGET(ingredient()),
IRON_SHEET(ingredient()),
GOLD_SHEET(ingredient()),
COPPER_SHEET(ingredient()),
BRASS_SHEET(ingredient()),
LAPIS_PLATE(ingredient()),
__MATERIALS__(module()),
COPPER_NUGGET,
ZINC_NUGGET,
BRASS_NUGGET,
IRON_SHEET,
GOLD_SHEET,
COPPER_SHEET,
BRASS_SHEET,
LAPIS_PLATE,
CRUSHED_IRON(ingredient()),
CRUSHED_GOLD(ingredient()),
CRUSHED_COPPER(ingredient()),
CRUSHED_ZINC(ingredient()),
CRUSHED_BRASS(ingredient()),
CRUSHED_IRON,
CRUSHED_GOLD,
CRUSHED_COPPER,
CRUSHED_ZINC,
CRUSHED_BRASS,
ANDESITE_ALLOY(ingredient()),
COPPER_INGOT(ingredient()),
ZINC_INGOT(ingredient()),
BRASS_INGOT(ingredient()),
SAND_PAPER(
new SandPaperItem(standardItemProperties().setTEISR(() -> () -> renderUsing(AllItemRenderers.SAND_PAPER)))),
RED_SAND_PAPER(
new SandPaperItem(standardItemProperties().setTEISR(() -> () -> renderUsing(AllItemRenderers.SAND_PAPER)))),
OBSIDIAN_DUST(ingredient()),
ROSE_QUARTZ(ingredient()),
POLISHED_ROSE_QUARTZ(ingredient()),
CHROMATIC_COMPOUND(new ChromaticCompoundCubeItem(standardItemProperties().rarity(Rarity.UNCOMMON))),
SHADOW_STEEL(new ShadowSteelItem(standardItemProperties().rarity(Rarity.UNCOMMON))),
REFINED_RADIANCE(new RefinedRadianceItem(standardItemProperties().rarity(Rarity.UNCOMMON))),
ELECTRON_TUBE(ingredient()),
INTEGRATED_CIRCUIT(ingredient()),
ANDESITE_ALLOY,
COPPER_INGOT,
ZINC_INGOT,
BRASS_INGOT,
__GARDENS__(),
TREE_FERTILIZER(new TreeFertilizerItem(standardItemProperties())),
SAND_PAPER(SandPaperItem::new),
RED_SAND_PAPER(SandPaperItem::new),
OBSIDIAN_DUST,
ROSE_QUARTZ,
POLISHED_ROSE_QUARTZ,
CHROMATIC_COMPOUND(ChromaticCompoundCubeItem::new, rarity(Rarity.UNCOMMON)),
SHADOW_STEEL(ShadowSteelItem::new, rarity(Rarity.UNCOMMON)),
REFINED_RADIANCE(RefinedRadianceItem::new, rarity(Rarity.UNCOMMON)),
ELECTRON_TUBE,
INTEGRATED_CIRCUIT,
__SCHEMATICS__(),
EMPTY_BLUEPRINT(new Item(standardItemProperties().maxStackSize(1))),
BLUEPRINT_AND_QUILL(new SchematicAndQuillItem(standardItemProperties().maxStackSize(1))),
BLUEPRINT(new SchematicItem(standardItemProperties())),
__SCHEMATICS__(module()),
EMPTY_BLUEPRINT(Item::new, stackSize(1)),
BLUEPRINT_AND_QUILL(SchematicAndQuillItem::new, stackSize(1)),
BLUEPRINT(SchematicItem::new),
__CONTRAPTIONS__(),
BELT_CONNECTOR(new BeltConnectorItem(standardItemProperties())),
VERTICAL_GEARBOX(new VerticalGearboxItem(new Properties())),
FLOUR(ingredient()),
DOUGH(ingredient()),
PROPELLER(ingredient()),
WHISK(ingredient()),
BRASS_HAND(ingredient()),
WRENCH(new WrenchItem(standardItemProperties().setTEISR(() -> () -> renderUsing(AllItemRenderers.WRENCH))), true),
GOGGLES(new GogglesItem(standardItemProperties()), true),
__CONTRAPTIONS__(module()),
BELT_CONNECTOR(BeltConnectorItem::new),
VERTICAL_GEARBOX(VerticalGearboxItem::new),
FLOUR,
DOUGH,
PROPELLER,
WHISK,
BRASS_HAND,
WRENCH(WrenchItem::new),
GOGGLES(GogglesItem::new),
__LOGISTICS__(),
FILTER(new FilterItem(standardItemProperties()), true),
PROPERTY_FILTER(new FilterItem(standardItemProperties()), true),
__LOGISTICS__(module()),
FILTER(FilterItem::new),
PROPERTY_FILTER(FilterItem::new),
__CURIOSITIES__(),
PLACEMENT_HANDGUN(
new BlockzapperItem(new Properties().setTEISR(() -> () -> renderUsing(AllItemRenderers.BUILDER_GUN))),
true),
DEFORESTER(
new DeforesterItem(standardItemProperties().setTEISR(() -> () -> renderUsing(AllItemRenderers.DEFORESTER))),
true),
SYMMETRY_WAND(new SymmetryWandItem(
standardItemProperties().setTEISR(() -> () -> renderUsing(AllItemRenderers.SYMMETRY_WAND))), true),
__CURIOSITIES__(module()),
TREE_FERTILIZER(TreeFertilizerItem::new),
PLACEMENT_HANDGUN(BlockzapperItem::new),
DEFORESTER(DeforesterItem::new),
SYMMETRY_WAND(SymmetryWandItem::new),
;
@ -115,11 +105,12 @@ public enum AllItems {
// Common
public Item item;
public IModule module;
public boolean firstInCreativeTab;
private Function<Properties, Properties> specialProperties;
private Function<Properties, Item> itemSupplier;
private Item item;
private AllItems() {
private AllItems(int moduleMarker) {
CategoryTracker.currentModule = new IModule() {
@Override
public String getModuleName() {
@ -128,36 +119,51 @@ public enum AllItems {
};
}
private AllItems(Item item) {
this(item, false);
private AllItems() {
this(Item::new);
}
private AllItems(Item item, boolean firstInCreativeTab) {
this.item = item;
this.item.setRegistryName(Create.ID, Lang.asId(name()));
private AllItems(Function<Properties, Item> itemSupplier) {
this(itemSupplier, Function.identity());
}
private AllItems(Function<Properties, Item> itemSupplier, Function<Properties, Properties> specialProperties) {
this.itemSupplier = itemSupplier;
this.module = CategoryTracker.currentModule;
this.firstInCreativeTab = firstInCreativeTab;
this.specialProperties = specialProperties;
}
public static Properties standardItemProperties() {
private static Function<Properties, Properties> rarity(Rarity rarity) {
return p -> p.rarity(rarity);
}
private static Function<Properties, Properties> stackSize(int stackSize) {
return p -> p.maxStackSize(stackSize);
}
private static Properties defaultProperties(AllItems item) {
return includeInItemGroup().setTEISR(() -> item::getRenderer);
}
private static int module() {
return 0;
}
public static Properties includeInItemGroup() {
return new Properties().group(Create.creativeTab);
}
private static Item ingredient() {
return ingredient(Rarity.COMMON);
}
private static Item ingredient(Rarity rarity) {
return new Item(standardItemProperties().rarity(rarity));
}
public static void register(RegistryEvent.Register<Item> event) {
IForgeRegistry<Item> registry = event.getRegistry();
for (AllItems item : values()) {
if (item.get() == null)
for (AllItems entry : values()) {
if (entry.itemSupplier == null)
continue;
registry.register(item.get());
entry.item = entry.itemSupplier.apply(new Properties());
entry.item = entry.itemSupplier.apply(entry.specialProperties.apply(defaultProperties(entry)));
entry.item.setRegistryName(Create.ID, Lang.asId(entry.name()));
registry.register(entry.item);
}
AllBlocks.registerItemBlocks(registry);
@ -177,8 +183,12 @@ public enum AllItems {
// Client
private enum AllItemRenderers {
SYMMETRY_WAND, BUILDER_GUN, WRENCH, DEFORESTER, SAND_PAPER;
@OnlyIn(Dist.CLIENT)
public ItemStackTileEntityRenderer getRenderer() {
if (!(item instanceof IHaveCustomItemModel))
return null;
IHaveCustomItemModel specialItem = (IHaveCustomItemModel) item;
return specialItem.createModel(null).getRenderer();
}
@OnlyIn(Dist.CLIENT)
@ -191,23 +201,4 @@ public enum AllItems {
}
}
@OnlyIn(Dist.CLIENT)
public static ItemStackTileEntityRenderer renderUsing(AllItemRenderers renderer) {
switch (renderer) {
case SYMMETRY_WAND:
return new SymmetryWandItemRenderer();
case BUILDER_GUN:
return new BlockzapperItemRenderer();
case WRENCH:
return new WrenchItemRenderer();
case DEFORESTER:
return new DeforesterItemRenderer();
case SAND_PAPER:
return new SandPaperItemRenderer();
default:
return null;
}
}
}

View file

@ -9,16 +9,13 @@ import com.simibubi.create.foundation.block.IHaveColoredVertices;
import com.simibubi.create.foundation.block.connected.CTModel;
import com.simibubi.create.foundation.block.connected.IHaveConnectedTextures;
import com.simibubi.create.foundation.block.render.ColoredVertexModel;
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
import com.simibubi.create.foundation.item.IHaveCustomItemModel;
import com.simibubi.create.foundation.utility.SuperByteBufferCache;
import com.simibubi.create.modules.contraptions.WrenchModel;
import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.modules.contraptions.components.contraptions.ContraptionRenderer;
import com.simibubi.create.modules.curiosities.blockzapper.BlockzapperModel;
import com.simibubi.create.modules.curiosities.deforester.DeforesterModel;
import com.simibubi.create.modules.curiosities.partialWindows.WindowInABlockModel;
import com.simibubi.create.modules.curiosities.symmetry.client.SymmetryWandModel;
import com.simibubi.create.modules.curiosities.tools.SandPaperItemRenderer.SandPaperModel;
import com.simibubi.create.modules.schematics.ClientSchematicLoader;
import com.simibubi.create.modules.schematics.client.SchematicAndQuillHandler;
import com.simibubi.create.modules.schematics.client.SchematicHandler;
@ -121,6 +118,7 @@ public class CreateClient {
public static void onModelBake(ModelBakeEvent event) {
Map<ResourceLocation, IBakedModel> modelRegistry = event.getModelRegistry();
// Swap Models for CT Blocks and Blocks with colored Vertices
for (AllBlocks allBlocks : AllBlocks.values()) {
Block block = allBlocks.get();
if (block == null)
@ -135,22 +133,19 @@ public class CreateClient {
}
swapModels(modelRegistry, getItemModelLocation(AllItems.SAND_PAPER),
t -> new SandPaperModel(t));
swapModels(modelRegistry, getItemModelLocation(AllItems.RED_SAND_PAPER),
t -> new SandPaperModel(t));
// Swap Models for custom rendered item models
for (AllItems item : AllItems.values()) {
if (!(item.get() instanceof IHaveCustomItemModel))
continue;
swapModels(modelRegistry, getItemModelLocation(AllItems.SYMMETRY_WAND),
t -> new SymmetryWandModel(t).loadPartials(event));
swapModels(modelRegistry, getItemModelLocation(AllItems.PLACEMENT_HANDGUN),
t -> new BlockzapperModel(t).loadPartials(event));
swapModels(modelRegistry, getItemModelLocation(AllItems.WRENCH), t -> new WrenchModel(t).loadPartials(event));
swapModels(modelRegistry, getItemModelLocation(AllItems.DEFORESTER),
t -> new DeforesterModel(t).loadPartials(event));
swapModels(modelRegistry,
getBlockModelLocation(AllBlocks.WINDOW_IN_A_BLOCK,
BlockModelShapes
.getPropertyMapString(AllBlocks.WINDOW_IN_A_BLOCK.get().getDefaultState().getValues())),
IHaveCustomItemModel specialItem = (IHaveCustomItemModel) item.get();
ModelResourceLocation location = new ModelResourceLocation(item.get().getRegistryName(), "inventory");
CustomRenderedItemModel model = specialItem.createModel(modelRegistry.get(location));
model.loadPartials(event);
modelRegistry.put(location, model);
}
swapModels(modelRegistry, getAllBlockStateModelLocations(AllBlocks.WINDOW_IN_A_BLOCK),
WindowInABlockModel::new);
swapModels(modelRegistry,
getBlockModelLocation(AllBlocks.WINDOW_IN_A_BLOCK,
@ -161,19 +156,20 @@ public class CreateClient {
@OnlyIn(Dist.CLIENT)
public static void onModelRegistry(ModelRegistryEvent event) {
for (String location : SymmetryWandModel.getCustomModelLocations())
ModelLoader.addSpecialModel(new ResourceLocation(Create.ID, "item/" + location));
for (String location : BlockzapperModel.getCustomModelLocations())
ModelLoader.addSpecialModel(new ResourceLocation(Create.ID, "item/" + location));
for (String location : WrenchModel.getCustomModelLocations())
ModelLoader.addSpecialModel(new ResourceLocation(Create.ID, "item/" + location));
for (String location : DeforesterModel.getCustomModelLocations())
ModelLoader.addSpecialModel(new ResourceLocation(Create.ID, "item/" + location));
// Register submodels for custom rendered item models
for (AllItems item : AllItems.values()) {
if (!(item.get() instanceof IHaveCustomItemModel))
continue;
IHaveCustomItemModel specialItem = (IHaveCustomItemModel) item.get();
CustomRenderedItemModel model = specialItem.createModel(null);
model.getModelLocations().forEach(ModelLoader::addSpecialModel);
}
}
@OnlyIn(Dist.CLIENT)
protected static ModelResourceLocation getItemModelLocation(AllItems item) {
return new ModelResourceLocation(item.item.getRegistryName(), "inventory");
return new ModelResourceLocation(item.get().getRegistryName(), "inventory");
}
@OnlyIn(Dist.CLIENT)

View file

@ -35,7 +35,6 @@ public class CreateConfig {
public BooleanValue enableContraptions;
public BooleanValue enablePalettes;
public BooleanValue enableLogistics;
public BooleanValue enableGardens;
// Damage Control
public BooleanValue freezeRotationPropagator;
@ -103,9 +102,6 @@ public class CreateConfig {
name = "enableCuriosities";
enableCuriosities = builder.translation(basePath + name).define(name, true);
name = "enableGardens";
enableGardens = builder.translation(basePath + name).define(name, true);
name = "enableLogistics";
enableLogistics = builder.translation(basePath + name).define(name, true);

View file

@ -4,9 +4,14 @@ import com.simibubi.create.foundation.block.IHaveNoBlockItem;
import com.simibubi.create.foundation.item.IAddedByOther;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public final class CreateItemGroup extends ItemGroup {
@ -20,12 +25,14 @@ public final class CreateItemGroup extends ItemGroup {
}
@Override
@OnlyIn(Dist.CLIENT)
public void fill(NonNullList<ItemStack> items) {
addItems(items, true);
addBlocks(items);
addItems(items, false);
}
@OnlyIn(Dist.CLIENT)
public void addBlocks(NonNullList<ItemStack> items) {
for (AllBlocks block : AllBlocks.values()) {
Block def = block.get();
@ -44,13 +51,17 @@ public final class CreateItemGroup extends ItemGroup {
}
}
public void addItems(NonNullList<ItemStack> items, boolean prioritized) {
@OnlyIn(Dist.CLIENT)
public void addItems(NonNullList<ItemStack> items, boolean specialItems) {
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
for (AllItems item : AllItems.values()) {
if (item.get() == null)
continue;
if (!item.module.isEnabled())
continue;
if (item.firstInCreativeTab != prioritized)
IBakedModel model = itemRenderer.getModelWithOverrides(item.asStack());
if ((model.isBuiltInRenderer() || model.isGui3d()) != specialItems)
continue;
if (item.get() instanceof IAddedByOther)
continue;

View file

@ -94,7 +94,7 @@ public class CreateJEI implements IModPlugin {
@Override
public void registerItemSubtypes(ISubtypeRegistration registration) {
registration.useNbtForSubtypes(AllItems.PLACEMENT_HANDGUN.item);
registration.useNbtForSubtypes(AllItems.PLACEMENT_HANDGUN.get());
}
@Override

View file

@ -1,28 +0,0 @@
package com.simibubi.create.foundation.block.render;
import com.simibubi.create.Create;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ModelRotation;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelBakeEvent;
public abstract class CustomRenderItemBakedModel extends WrappedBakedModel {
public CustomRenderItemBakedModel(IBakedModel template) {
super(template);
}
public abstract CustomRenderItemBakedModel loadPartials(ModelBakeEvent event);
@Override
public boolean isBuiltInRenderer() {
return true;
}
protected static IBakedModel loadCustomModel(ModelBakeEvent event, String name) {
return event.getModelLoader().func_217845_a(new ResourceLocation(Create.ID, "item/" + name),
ModelRotation.X0_Y0);
}
}

View file

@ -0,0 +1,83 @@
package com.simibubi.create.foundation.block.render;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.vecmath.Matrix4f;
import org.apache.commons.lang3.tuple.Pair;
import com.simibubi.create.Create;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.model.ModelRotation;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelBakeEvent;
@SuppressWarnings("deprecation")
public abstract class CustomRenderedItemModel extends WrappedBakedModel {
protected String basePath;
protected Map<String, IBakedModel> partials = new HashMap<>();
protected TransformType currentPerspective;
protected ItemStackTileEntityRenderer renderer;
public CustomRenderedItemModel(IBakedModel template, String basePath) {
super(template);
this.basePath = basePath;
this.renderer = createRenderer();
}
public final List<ResourceLocation> getModelLocations() {
return partials.keySet().stream().map(this::getPartialModelLocation).collect(Collectors.toList());
}
public ItemStackTileEntityRenderer getRenderer() {
return renderer;
}
public abstract ItemStackTileEntityRenderer createRenderer();
@Override
public boolean isBuiltInRenderer() {
return true;
}
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
currentPerspective = cameraTransformType;
return super.handlePerspective(cameraTransformType);
}
protected void addPartials(String... partials) {
this.partials.clear();
for (String name : partials)
this.partials.put(name, null);
}
public void loadPartials(ModelBakeEvent event) {
for (String name : partials.keySet())
partials.put(name, loadModel(event, name));
}
private IBakedModel loadModel(ModelBakeEvent event, String name) {
return event.getModelLoader().func_217845_a(getPartialModelLocation(name), ModelRotation.X0_Y0);
}
private ResourceLocation getPartialModelLocation(String name) {
return new ResourceLocation(Create.ID, "item/" + basePath + "/" + name);
}
public TransformType getCurrentPerspective() {
return currentPerspective;
}
public IBakedModel getPartial(String name) {
return partials.get(name);
}
}

View file

@ -0,0 +1,16 @@
package com.simibubi.create.foundation.item;
import javax.annotation.Nullable;
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public interface IHaveCustomItemModel {
@OnlyIn(value = Dist.CLIENT)
public CustomRenderedItemModel createModel(@Nullable IBakedModel original);
}

View file

@ -28,8 +28,6 @@ public interface IModule {
return conf.enableLogistics.get();
case "schematics":
return conf.enableSchematics.get();
case "gardens":
return conf.enableGardens.get();
default:
return false;
}
@ -45,15 +43,13 @@ public interface IModule {
case "contraptions":
return Palette.Red;
case "palettes":
return Palette.Yellow;
return Palette.Green;
case "curiosities":
return Palette.Purple;
case "logistics":
return Palette.Yellow;
case "schematics":
return Palette.Blue;
case "gardens":
return Palette.Green;
default:
return Palette.Purple;
}

View file

@ -1,7 +1,11 @@
package com.simibubi.create.modules.contraptions;
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
import com.simibubi.create.foundation.item.IHaveCustomItemModel;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -10,8 +14,10 @@ import net.minecraft.util.ActionResultType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class WrenchItem extends Item {
public class WrenchItem extends Item implements IHaveCustomItemModel {
public WrenchItem(Properties properties) {
super(properties);
@ -45,4 +51,10 @@ public class WrenchItem extends Item {
return actor.onWrenched(state, context);
}
@Override
@OnlyIn(Dist.CLIENT)
public CustomRenderedItemModel createModel(IBakedModel original) {
return new WrenchModel(original);
}
}

View file

@ -29,7 +29,7 @@ public class WrenchItemRenderer extends ItemStackTileEntityRenderer {
GlStateManager.rotated(angle, 0, 1, 0);
GlStateManager.translatef(xOffset, 0, zOffset);
itemRenderer.renderItem(stack, mainModel.gear);
itemRenderer.renderItem(stack, mainModel.getPartial("gear"));
GlStateManager.popMatrix();
}

View file

@ -1,29 +1,20 @@
package com.simibubi.create.modules.contraptions;
import java.util.Arrays;
import java.util.List;
import com.simibubi.create.foundation.block.render.CustomRenderItemBakedModel;
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
public class WrenchModel extends CustomRenderItemBakedModel {
public IBakedModel gear;
public class WrenchModel extends CustomRenderedItemModel {
public WrenchModel(IBakedModel template) {
super(template);
}
public static List<String> getCustomModelLocations() {
return Arrays.asList("wrench/gear");
super(template, "wrench");
addPartials("gear");
}
@Override
public CustomRenderItemBakedModel loadPartials(ModelBakeEvent event) {
this.gear = loadCustomModel(event, "wrench/gear");
return this;
public ItemStackTileEntityRenderer createRenderer() {
return new WrenchItemRenderer();
}
}

View file

@ -1,6 +1,7 @@
package com.simibubi.create.modules.contraptions.relays.gearbox;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.item.IAddedByOther;
import com.simibubi.create.modules.contraptions.base.IRotate;
import net.minecraft.block.BlockState;
@ -13,7 +14,7 @@ import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class VerticalGearboxItem extends BlockItem {
public class VerticalGearboxItem extends BlockItem implements IAddedByOther {
public VerticalGearboxItem(Properties builder) {
super(AllBlocks.GEARBOX.get(), builder);

View file

@ -11,7 +11,9 @@ import com.google.common.base.Predicates;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllPackets;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.item.IHaveCustomItemModel;
import com.simibubi.create.foundation.item.ItemDescription;
import com.simibubi.create.foundation.item.ItemDescription.Palette;
import com.simibubi.create.foundation.utility.BlockHelper;
@ -23,6 +25,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
@ -67,7 +70,7 @@ import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.network.PacketDistributor;
public class BlockzapperItem extends Item {
public class BlockzapperItem extends Item implements IHaveCustomItemModel {
public static enum ComponentTier {
None(TextFormatting.DARK_GRAY), Brass(TextFormatting.GOLD), Chromatic(TextFormatting.LIGHT_PURPLE),
@ -589,4 +592,10 @@ public class BlockzapperItem extends Item {
stack.getOrCreateTag().putString(component.name(), NBTHelper.writeEnum(tier));
}
@Override
@OnlyIn(value = Dist.CLIENT)
public CustomRenderedItemModel createModel(IBakedModel original) {
return new BlockzapperModel(original);
}
}

View file

@ -18,12 +18,14 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.HandSide;
import net.minecraft.util.math.MathHelper;
@SuppressWarnings("deprecation")
public class BlockzapperItemRenderer extends ItemStackTileEntityRenderer {
@Override
@ -40,13 +42,14 @@ public class BlockzapperItemRenderer extends ItemStackTileEntityRenderer {
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, Math.min(lastCoordx + 60, 240), Math.min(lastCoordy + 120, 240));
itemRenderer.renderItem(stack, mainModel.getBakedModel());
renderComponent(stack, Body, itemRenderer, mainModel.body, mainModel.goldBody, mainModel.chorusBody);
renderComponent(stack, Amplifier, itemRenderer, null, mainModel.goldAmp, mainModel.chorusAmp);
renderComponent(stack, Retriever, itemRenderer, null, mainModel.goldRetriever, mainModel.chorusRetriever);
renderComponent(stack, Scope, itemRenderer, null, mainModel.goldScope, mainModel.chorusScope);
renderComponent(stack, mainModel, Body, itemRenderer);
renderComponent(stack, mainModel, Amplifier, itemRenderer);
renderComponent(stack, mainModel, Retriever, itemRenderer);
renderComponent(stack, mainModel, Scope, itemRenderer);
// Block indicator
if (mainModel.showBlock && stack.hasTag() && stack.getTag().contains("BlockUsed"))
if (mainModel.getCurrentPerspective() == TransformType.GUI && stack.hasTag()
&& stack.getTag().contains("BlockUsed"))
renderBlockUsed(stack, itemRenderer);
ClientPlayerEntity player = Minecraft.getInstance().player;
@ -66,9 +69,9 @@ public class BlockzapperItemRenderer extends ItemStackTileEntityRenderer {
multiplier = animation;
}
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, multiplier * 240, 120);
itemRenderer.renderItem(stack, mainModel.core);
itemRenderer.renderItem(stack, mainModel.getPartial("core"));
if (BlockzapperItem.getTier(Amplifier, stack) != ComponentTier.None)
itemRenderer.renderItem(stack, mainModel.ampCore);
itemRenderer.renderItem(stack, mainModel.getPartial("amplifier_core"));
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, lastCoordx, lastCoordy);
GlStateManager.enableLighting();
@ -82,7 +85,7 @@ public class BlockzapperItemRenderer extends ItemStackTileEntityRenderer {
GlStateManager.translatef(0, offset, 0);
GlStateManager.rotatef(angle, 0, 0, 1);
GlStateManager.translatef(0, -offset, 0);
renderComponent(stack, Accelerator, itemRenderer, mainModel.acc, mainModel.goldAcc, mainModel.chorusAcc);
renderComponent(stack, mainModel, Accelerator, itemRenderer);
GlStateManager.popMatrix();
}
@ -103,18 +106,12 @@ public class BlockzapperItemRenderer extends ItemStackTileEntityRenderer {
GlStateManager.popMatrix();
}
public void renderComponent(ItemStack stack, Components component, ItemRenderer itemRenderer, IBakedModel none,
IBakedModel gold, IBakedModel chorus) {
public void renderComponent(ItemStack stack, BlockzapperModel model, Components component,
ItemRenderer itemRenderer) {
ComponentTier tier = BlockzapperItem.getTier(component, stack);
IBakedModel model = tier == ComponentTier.Chromatic ? chorus : gold;
if (tier == ComponentTier.None) {
if (none == null)
return;
model = none;
}
itemRenderer.renderItem(stack, model);
IBakedModel partial = model.getComponentPartial(tier, component);
if (partial != null)
itemRenderer.renderItem(stack, partial);
}
}

View file

@ -1,79 +1,32 @@
package com.simibubi.create.modules.curiosities.blockzapper;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
import org.apache.commons.lang3.tuple.Pair;
import com.simibubi.create.foundation.block.render.CustomRenderItemBakedModel;
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.modules.curiosities.blockzapper.BlockzapperItem.ComponentTier;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
@SuppressWarnings("deprecation")
public class BlockzapperModel extends CustomRenderItemBakedModel {
public boolean showBlock;
public IBakedModel core;
public IBakedModel body;
public IBakedModel ampCore;
public IBakedModel acc;
public IBakedModel goldBody;
public IBakedModel goldScope;
public IBakedModel goldAmp;
public IBakedModel goldRetriever;
public IBakedModel goldAcc;
public IBakedModel chorusBody;
public IBakedModel chorusScope;
public IBakedModel chorusAmp;
public IBakedModel chorusRetriever;
public IBakedModel chorusAcc;
public class BlockzapperModel extends CustomRenderedItemModel {
public BlockzapperModel(IBakedModel template) {
super(template);
}
public static List<String> getCustomModelLocations() {
String p = "blockzapper/";
return Arrays.asList(p + "core", p + "body", p + "amplifier_core", p + "accelerator", p + "gold_body",
p + "gold_scope", p + "gold_amplifier", p + "gold_retriever", p + "gold_accelerator", p + "chorus_body",
p + "chorus_amplifier", p + "chorus_retriever", p + "chorus_accelerator");
super(template, "blockzapper");
addPartials("core", "body", "amplifier_core", "accelerator", "gold_body", "gold_scope", "gold_amplifier",
"gold_retriever", "gold_accelerator", "chorus_body", "chorus_amplifier", "chorus_retriever",
"chorus_accelerator");
}
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
showBlock = cameraTransformType == TransformType.GUI;
return super.handlePerspective(cameraTransformType);
public ItemStackTileEntityRenderer createRenderer() {
return new BlockzapperItemRenderer();
}
@Override
public CustomRenderItemBakedModel loadPartials(ModelBakeEvent event) {
String p = "blockzapper/";
this.core = loadCustomModel(event, p + "core");
this.body = loadCustomModel(event, p + "body");
this.ampCore = loadCustomModel(event, p + "amplifier_core");
this.acc = loadCustomModel(event, p + "accelerator");
this.goldBody = loadCustomModel(event, p + "gold_body");
this.goldScope = loadCustomModel(event, p + "gold_scope");
this.goldAmp = loadCustomModel(event, p + "gold_amplifier");
this.goldRetriever = loadCustomModel(event, p + "gold_retriever");
this.goldAcc = loadCustomModel(event, p + "gold_accelerator");
this.chorusBody = loadCustomModel(event, p + "chorus_body");
this.chorusScope = loadCustomModel(event, p + "chorus_scope");
this.chorusAmp = loadCustomModel(event, p + "chorus_amplifier");
this.chorusRetriever = loadCustomModel(event, p + "chorus_retriever");
this.chorusAcc = loadCustomModel(event, p + "chorus_accelerator");
return this;
@Nullable
IBakedModel getComponentPartial(BlockzapperItem.ComponentTier tier, BlockzapperItem.Components component) {
String prefix = tier == ComponentTier.Chromatic ? "chorus_" : tier == ComponentTier.Brass ? "gold_" : "";
return getPartial(prefix + Lang.asId(component.name()));
}
}

View file

@ -1,6 +1,8 @@
package com.simibubi.create.modules.curiosities.deforester;
import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
import com.simibubi.create.foundation.item.IHaveCustomItemModel;
import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.TreeCutter;
import com.simibubi.create.foundation.utility.TreeCutter.Tree;
@ -8,6 +10,7 @@ import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.modules.curiosities.tools.AllToolTiers;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.AxeItem;
@ -18,13 +21,15 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
@EventBusSubscriber(bus = Bus.FORGE)
public class DeforesterItem extends AxeItem {
public class DeforesterItem extends AxeItem implements IHaveCustomItemModel {
public DeforesterItem(Properties builder) {
super(AllToolTiers.RADIANT, 10.0F, -3.1F, builder);
@ -75,4 +80,10 @@ public class DeforesterItem extends AxeItem {
world.addEntity(entity);
}
@Override
@OnlyIn(Dist.CLIENT)
public CustomRenderedItemModel createModel(IBakedModel original) {
return new DeforesterModel(original);
}
}

View file

@ -26,8 +26,8 @@ public class DeforesterItemRenderer extends ItemStackTileEntityRenderer {
GlStateManager.disableLighting();
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, 240, 120);
itemRenderer.renderItem(stack, mainModel.light);
itemRenderer.renderItem(stack, mainModel.blade);
itemRenderer.renderItem(stack, mainModel.getPartial("light"));
itemRenderer.renderItem(stack, mainModel.getPartial("blade"));
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, lastCoordx, lastCoordy);
GlStateManager.enableLighting();
@ -38,7 +38,7 @@ public class DeforesterItemRenderer extends ItemStackTileEntityRenderer {
GlStateManager.rotated(angle, 0, 1, 0);
GlStateManager.translatef(xOffset, 0, zOffset);
itemRenderer.renderItem(stack, mainModel.gear);
itemRenderer.renderItem(stack, mainModel.getPartial("gear"));
GlStateManager.popMatrix();

View file

@ -1,33 +1,20 @@
package com.simibubi.create.modules.curiosities.deforester;
import java.util.Arrays;
import java.util.List;
import com.simibubi.create.foundation.block.render.CustomRenderItemBakedModel;
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
public class DeforesterModel extends CustomRenderItemBakedModel {
public IBakedModel gear;
public IBakedModel light;
public IBakedModel blade;
public class DeforesterModel extends CustomRenderedItemModel {
public DeforesterModel(IBakedModel template) {
super(template);
}
public static List<String> getCustomModelLocations() {
return Arrays.asList("deforester/gear", "deforester/light", "deforester/blade");
super(template, "deforester");
addPartials("gear", "light", "blade");
}
@Override
public CustomRenderItemBakedModel loadPartials(ModelBakeEvent event) {
this.gear = loadCustomModel(event, "deforester/gear");
this.light = loadCustomModel(event, "deforester/light");
this.blade = loadCustomModel(event, "deforester/blade");
return this;
public ItemStackTileEntityRenderer createRenderer() {
return new DeforesterItemRenderer();
}
}

View file

@ -8,8 +8,11 @@ import java.util.List;
import java.util.Map;
import com.simibubi.create.AllPackets;
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.item.IHaveCustomItemModel;
import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.modules.curiosities.symmetry.client.SymmetryWandModel;
import com.simibubi.create.modules.curiosities.symmetry.mirror.CrossPlaneMirror;
import com.simibubi.create.modules.curiosities.symmetry.mirror.EmptyMirror;
import com.simibubi.create.modules.curiosities.symmetry.mirror.PlaneMirror;
@ -18,6 +21,7 @@ import com.simibubi.create.modules.curiosities.symmetry.mirror.SymmetryMirror;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
@ -39,7 +43,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.network.PacketDistributor;
public class SymmetryWandItem extends Item {
public class SymmetryWandItem extends Item implements IHaveCustomItemModel {
public static final String SYMMETRY = "symmetry";
private static final String ENABLE = "enable";
@ -268,4 +272,10 @@ public class SymmetryWandItem extends Item {
new SymmetryEffectPacket(to, targets));
}
@Override
@OnlyIn(Dist.CLIENT)
public CustomRenderedItemModel createModel(IBakedModel original) {
return new SymmetryWandModel(original);
}
}

View file

@ -31,13 +31,13 @@ public class SymmetryWandItemRenderer extends ItemStackTileEntityRenderer {
lastCoordy = GLX.lastBrightnessY;
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, 240, 240);
itemRenderer.renderItem(stack, mainModel.core);
itemRenderer.renderItem(stack, mainModel.getPartial("core"));
float floating = MathHelper.sin(worldTime) * .05f;
GlStateManager.translated(0, floating, 0);
float angle = worldTime * -10 % 360;
GlStateManager.rotated(angle, 0, 1, 0);
itemRenderer.renderItem(stack, mainModel.bits);
itemRenderer.renderItem(stack, mainModel.getPartial("bits"));
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, lastCoordx, lastCoordy);
GlStateManager.enableLighting();

View file

@ -1,31 +1,20 @@
package com.simibubi.create.modules.curiosities.symmetry.client;
import java.util.Arrays;
import java.util.List;
import com.simibubi.create.foundation.block.render.CustomRenderItemBakedModel;
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
public class SymmetryWandModel extends CustomRenderItemBakedModel {
public IBakedModel core;
public IBakedModel bits;
public class SymmetryWandModel extends CustomRenderedItemModel {
public SymmetryWandModel(IBakedModel template) {
super(template);
}
public static List<String> getCustomModelLocations() {
return Arrays.asList("symmetry_wand_core", "symmetry_wand_bits");
super(template, "symmetry_wand");
addPartials("bits", "core");
}
@Override
public CustomRenderItemBakedModel loadPartials(ModelBakeEvent event) {
this.core = loadCustomModel(event, "symmetry_wand_core");
this.bits = loadCustomModel(event, "symmetry_wand_bits");
return this;
public ItemStackTileEntityRenderer createRenderer() {
return new SymmetryWandItemRenderer();
}
}

View file

@ -16,15 +16,15 @@ public enum AllToolTiers implements IItemTier {
}),
ROSE_QUARTZ(3, 1644, 7.0F, 2.0F, 24, () -> {
return Ingredient.fromItems(AllItems.POLISHED_ROSE_QUARTZ.item);
return Ingredient.fromItems(AllItems.POLISHED_ROSE_QUARTZ.get());
}),
SHADOW_STEEL(4, 2303, 16.0F, 3.5F, 10, () -> {
return Ingredient.fromItems(AllItems.SHADOW_STEEL.item);
return Ingredient.fromItems(AllItems.SHADOW_STEEL.get());
}),
RADIANT(4, 1024, 16.0F, 3.5F, 10, () -> {
return Ingredient.fromItems(AllItems.REFINED_RADIANCE.item);
return Ingredient.fromItems(AllItems.REFINED_RADIANCE.get());
}),
;

View file

@ -1,8 +1,12 @@
package com.simibubi.create.modules.curiosities.tools;
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
import com.simibubi.create.foundation.item.IHaveCustomItemModel;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.modules.contraptions.components.deployer.DeployerFakePlayer;
import com.simibubi.create.modules.curiosities.tools.SandPaperItemRenderer.SandPaperModel;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.LivingEntity;
@ -24,8 +28,10 @@ import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class SandPaperItem extends Item {
public class SandPaperItem extends Item implements IHaveCustomItemModel {
public SandPaperItem(Properties properties) {
super(properties);
@ -177,4 +183,10 @@ public class SandPaperItem extends Item {
return 8;
}
@Override
@OnlyIn(Dist.CLIENT)
public CustomRenderedItemModel createModel(IBakedModel original) {
return new SandPaperModel(original);
}
}

View file

@ -1,11 +1,7 @@
package com.simibubi.create.modules.curiosities.tools;
import javax.vecmath.Matrix4f;
import org.apache.commons.lang3.tuple.Pair;
import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.foundation.block.render.CustomRenderItemBakedModel;
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft;
@ -17,7 +13,6 @@ import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.client.event.ModelBakeEvent;
@SuppressWarnings("deprecation")
public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
@ -27,10 +22,11 @@ public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
ClientPlayerEntity player = Minecraft.getInstance().player;
SandPaperModel mainModel = (SandPaperModel) itemRenderer.getModelWithOverrides(stack);
TransformType perspective = mainModel.getCurrentPerspective();
float partialTicks = Minecraft.getInstance().getRenderPartialTicks();
boolean leftHand = mainModel.transformType == TransformType.FIRST_PERSON_LEFT_HAND;
boolean firstPerson = leftHand || mainModel.transformType == TransformType.FIRST_PERSON_RIGHT_HAND;
boolean leftHand = perspective == TransformType.FIRST_PERSON_LEFT_HAND;
boolean firstPerson = leftHand || perspective == TransformType.FIRST_PERSON_RIGHT_HAND;
GlStateManager.pushMatrix();
GlStateManager.translatef(.5f, .5f, .5f);
@ -41,7 +37,7 @@ public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
if (tag.contains("Polishing")) {
GlStateManager.pushMatrix();
if (mainModel.transformType == TransformType.GUI) {
if (perspective == TransformType.GUI) {
GlStateManager.translatef(0.0F, .2f, 1.0F);
GlStateManager.scalef(.75f, .75f, .75f);
} else {
@ -55,7 +51,7 @@ public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
if (time / (float) stack.getUseDuration() < 0.8F) {
float bobbing = -MathHelper.abs(MathHelper.cos(time / 4.0F * (float) Math.PI) * 0.1F);
if (mainModel.transformType == TransformType.GUI)
if (perspective == TransformType.GUI)
GlStateManager.translatef(bobbing, bobbing, 0.0F);
else
GlStateManager.translatef(0.0f, bobbing, 0.0F);
@ -83,23 +79,15 @@ public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
GlStateManager.popMatrix();
}
public static class SandPaperModel extends CustomRenderItemBakedModel {
TransformType transformType;
public static class SandPaperModel extends CustomRenderedItemModel {
public SandPaperModel(IBakedModel template) {
super(template);
super(template, "");
}
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
transformType = cameraTransformType;
return super.handlePerspective(cameraTransformType);
}
@Override
public CustomRenderItemBakedModel loadPartials(ModelBakeEvent event) {
return this;
public ItemStackTileEntityRenderer createRenderer() {
return new SandPaperItemRenderer();
}
}

View file

@ -47,7 +47,7 @@ public class SchematicItem extends Item {
}
public static ItemStack create(String schematic, String owner) {
ItemStack blueprint = new ItemStack(AllItems.BLUEPRINT.item);
ItemStack blueprint = AllItems.BLUEPRINT.asStack();
CompoundNBT tag = new CompoundNBT();
tag.putBoolean("Deployed", false);

View file

@ -2,7 +2,7 @@
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
"parent": "create:item/placement_handgun",
"textures": {
"cog": "minecraft:block/purpur_block"
"cog": "minecraft:block/mycelium_top"
},
"elements": [
{

View file

@ -2,7 +2,7 @@
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
"parent": "create:item/placement_handgun",
"textures": {
"cog": "minecraft:block/yellow_concrete_powder"
"cog": "create:block/brass_block"
},
"elements": [
{

View file

@ -1,156 +1,126 @@
{
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
"ambientocclusion": true,
"display": {
"firstperson_righthand": {
"rotation": [ 15, 0, 0 ],
"translation": [ 0, 0, -2],
"scale":[ 0.6, 0.6, 0.6 ]
},
"thirdperson_righthand": {
"rotation": [ 15, 0, 0 ],
"translation": [ -1, 1, 1],
"scale":[ 0.5, 0.5, 0.5 ]
},
"gui": {
"rotation": [ 42, 135, 32 ],
"translation": [ -1.7, -1.7, 3],
"scale":[ 0.8, 0.8, 0.8 ]
},
"ground": {
"rotation": [ 0, 0, 0 ],
"translation": [ 0, 4.2, 0],
"scale":[ 0.4, 0.4, 0.4 ]
},
"fixed": {
"rotation": [ 0, 90, 0 ],
"translation": [ 0, -5, 0 ],
"scale": [ 1, 1, 1 ]
}
},
"credit": "Made with Blockbench",
"textures": {
"0": "block/obsidian",
"1": "block/packed_ice",
"2": "block/dark_oak_log",
"3": "block/white_stained_glass",
"4": "block/light_blue_stained_glass",
"5": "block/white_concrete_powder"
"6": "create:block/brass_block",
"7": "create:block/andesite_casing",
"particle": "create:block/brass_block"
},
"elements": [
{
"name": "Grip Core",
"from": [ 6.5, -5.0, 6.5 ],
"to": [ 9.5, 6.0, 9.5 ],
"from": [6.5, -5, 6.5],
"to": [9.5, 6, 9.5],
"faces": {
"north": { "texture": "#0", "uv": [ 5.0, 1.0, 8.0, 12.0 ] },
"east": { "texture": "#0", "uv": [ 2.0, 3.0, 5.0, 14.0 ] },
"south": { "texture": "#0", "uv": [ 10.0, 1.0, 13.0, 12.0 ] },
"west": { "texture": "#0", "uv": [ 7.0, 1.0, 10.0, 12.0 ] },
"up": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 3.0 ] },
"down": { "texture": "#0", "uv": [ 5.0, 6.0, 8.0, 9.0 ] }
"north": {"uv": [5, 1, 8, 12], "texture": "#0"},
"east": {"uv": [2, 3, 5, 14], "texture": "#0"},
"south": {"uv": [10, 1, 13, 12], "texture": "#0"},
"west": {"uv": [7, 1, 10, 12], "texture": "#0"},
"up": {"uv": [0, 0, 3, 3], "texture": "#0"},
"down": {"uv": [5, 6, 8, 9], "texture": "#0"}
}
},
{
"name": "Rod Bottom Core",
"from": [ 6.5, 8.0, 6.5 ],
"to": [ 9.5, 17.0, 9.5 ],
"rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "y", "angle": 45.0 },
"from": [6.5, 7, 6.5],
"to": [9.5, 17, 9.5],
"rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]},
"faces": {
"north": { "texture": "#1", "uv": [ 5.0, 7.0, 8.0, 16.0 ] },
"east": { "texture": "#1", "uv": [ 7.0, 7.0, 10.0, 16.0 ] },
"south": { "texture": "#1", "uv": [ 1.0, 7.0, 4.0, 16.0 ] },
"west": { "texture": "#1", "uv": [ 3.0, 7.0, 6.0, 16.0 ] },
"up": { "texture": "#1", "uv": [ 12.0, 1.0, 15.0, 4.0 ] },
"down": { "texture": "#2", "uv": [ 8.0, 10.0, 11.0, 13.0 ] }
"north": {"uv": [5, 6, 8, 16], "texture": "#6"},
"east": {"uv": [2, 6, 5, 16], "texture": "#6"},
"south": {"uv": [11, 6, 14, 16], "texture": "#6"},
"west": {"uv": [8, 6, 11, 16], "texture": "#6"},
"up": {"uv": [12, 1, 15, 4], "texture": "#6"},
"down": {"uv": [8, 10, 11, 13], "texture": "#6"}
}
},
{
"name": "Grip Cap",
"from": [ 6.0, 6.0, 6.0 ],
"to": [ 10.0, 7.0, 10.0 ],
"from": [6, 6, 6],
"to": [10, 7, 10],
"faces": {
"north": { "texture": "#2", "uv": [ 2.0, 0.0, 6.0, 1.0 ] },
"east": { "texture": "#2", "uv": [ 0.0, 0.0, 4.0, 1.0 ] },
"south": { "texture": "#2", "uv": [ 0.0, 0.0, 4.0, 1.0 ] },
"west": { "texture": "#2", "uv": [ 0.0, 1.0, 4.0, 2.0 ] },
"up": { "texture": "#2", "uv": [ 10.0, 15.0, 14.0, 11.0 ] },
"down": { "texture": "#2", "uv": [ 5.0, 3.0, 9.0, 7.0 ] }
"north": {"uv": [2, 0, 6, 1], "texture": "#2"},
"east": {"uv": [0, 0, 4, 1], "texture": "#2"},
"south": {"uv": [0, 0, 4, 1], "texture": "#2"},
"west": {"uv": [0, 1, 4, 2], "texture": "#2"},
"up": {"uv": [10, 15, 14, 11], "texture": "#2"},
"down": {"uv": [5, 3, 9, 7], "texture": "#2"}
}
},
{
"name": "Rod Top Core",
"from": [ 6.5, 27.0, 6.5 ],
"to": [ 9.5, 30.0, 9.5 ],
"rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "y", "angle": 45.0 },
"from": [6.5, 27, 6.5],
"to": [9.5, 30, 9.5],
"rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]},
"faces": {
"north": { "texture": "#1", "uv": [ 1.0, 4.0, 4.0, 7.0 ] },
"east": { "texture": "#1", "uv": [ 1.0, 4.0, 4.0, 7.0 ] },
"south": { "texture": "#1", "uv": [ 1.0, 4.0, 4.0, 7.0 ] },
"west": { "texture": "#1", "uv": [ 1.0, 4.0, 4.0, 7.0 ] },
"up": { "texture": "#1", "uv": [ 12.0, 1.0, 15.0, 4.0 ] },
"down": { "texture": "#1", "uv": [ 12.0, 1.0, 15.0, 4.0 ] }
"north": {"uv": [8, 1, 11, 4], "texture": "#6"},
"east": {"uv": [7, 1, 10, 4], "texture": "#6"},
"south": {"uv": [5, 1, 8, 4], "texture": "#6"},
"west": {"uv": [3, 1, 6, 4], "texture": "#6"},
"up": {"uv": [12, 1, 15, 4], "texture": "#6"},
"down": {"uv": [12, 1, 15, 4], "texture": "#6"}
}
},
{
"name": "Cap",
"from": [ 6.0, 30.0, 6.0 ],
"to": [ 10.0, 31.0, 10.0 ],
"from": [6, 30, 6],
"to": [10, 31, 10],
"faces": {
"north": { "texture": "#2", "uv": [ 0.0, 0.0, 4.0, 1.0 ] },
"east": { "texture": "#2", "uv": [ 0.0, 0.0, 4.0, 1.0 ] },
"south": { "texture": "#2", "uv": [ 0.0, 0.0, 4.0, 1.0 ] },
"west": { "texture": "#2", "uv": [ 0.0, 0.0, 4.0, 1.0 ] },
"up": { "texture": "#2", "uv": [ 7.0, 10.0, 11.0, 14.0 ] },
"down": { "texture": "#2", "uv": [ 7.0, 10.0, 11.0, 14.0 ] }
"north": {"uv": [0, 0, 4, 1], "texture": "#2"},
"east": {"uv": [0, 0, 4, 1], "texture": "#2"},
"south": {"uv": [0, 0, 4, 1], "texture": "#2"},
"west": {"uv": [0, 0, 4, 1], "texture": "#2"},
"up": {"uv": [7, 10, 11, 14], "texture": "#2"},
"down": {"uv": [7, 10, 11, 14], "texture": "#2"}
}
},
{
"name": "Grip Deco",
"from": [ 6.3000000193715096, 4.0, 6.3000000193715096 ],
"to": [ 9.700000025331974, 5.0, 9.700000025331974 ],
"from": [6.3, 4, 6.3],
"to": [9.7, 5, 9.7],
"faces": {
"north": { "texture": "#2", "uv": [ 2.0, 7.0, 5.4000000059604645, 8.0 ] },
"east": { "texture": "#2", "uv": [ 4.0, 7.0, 7.4000000059604645, 8.0 ] },
"south": { "texture": "#2", "uv": [ 6.0, 7.0, 9.400000005960464, 8.0 ] },
"west": { "texture": "#2", "uv": [ 7.0, 7.0, 10.400000005960464, 8.0 ] }
"north": {"uv": [4, 1, 7, 2], "texture": "#7"},
"east": {"uv": [4, 1, 7, 2], "texture": "#7"},
"south": {"uv": [4, 1, 7, 2], "texture": "#7"},
"west": {"uv": [4, 1, 7, 2], "texture": "#7"}
}
},
{
"name": "Rod Bottom Deco 1",
"from": [ 7.5, 9.0, 5.5 ],
"to": [ 8.5, 10.0, 10.5 ],
"name": "Grip Deco",
"from": [6.3, -4, 6.3],
"to": [9.7, -3, 9.7],
"faces": {
"north": { "texture": "#2", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
"east": { "texture": "#2", "uv": [ 0.0, 0.0, 5.0, 1.0 ] },
"south": { "texture": "#2", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
"west": { "texture": "#2", "uv": [ 0.0, 0.0, 5.0, 1.0 ] },
"up": { "texture": "#2", "uv": [ 0.0, 0.0, 1.0, 5.0 ] },
"down": { "texture": "#2", "uv": [ 0.0, 0.0, 1.0, 5.0 ] }
"north": {"uv": [4, 1, 7, 2], "texture": "#7"},
"east": {"uv": [4, 1, 7, 2], "texture": "#7"},
"south": {"uv": [4, 1, 7, 2], "texture": "#7"},
"west": {"uv": [4, 1, 7, 2], "texture": "#7"}
}
}
],
"display": {
"thirdperson_righthand": {
"rotation": [15, 0, 0],
"translation": [-1, 1, 1],
"scale": [0.5, 0.5, 0.5]
},
{
"name": "Rod Bottom Deco 2",
"from": [ 5.5, 9.0, 7.5 ],
"to": [ 10.5, 10.0, 8.5 ],
"faces": {
"north": { "texture": "#2", "uv": [ 0.0, 0.0, 5.0, 1.0 ] },
"east": { "texture": "#2", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
"south": { "texture": "#2", "uv": [ 0.0, 0.0, 5.0, 1.0 ] },
"west": { "texture": "#2", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
"up": { "texture": "#2", "uv": [ 0.0, 0.0, 5.0, 1.0 ] },
"down": { "texture": "#2", "uv": [ 0.0, 0.0, 5.0, 1.0 ] }
}
"firstperson_righthand": {
"rotation": [15, 0, 0],
"translation": [0, 0, -2],
"scale": [0.6, 0.6, 0.6]
},
{
"name": "Cube",
"from": [ 6.3000000193715096, -4.0, 6.3000000193715096 ],
"to": [ 9.700000025331974, -3.0, 9.700000025331974 ],
"faces": {
"north": { "texture": "#2", "uv": [ 5.0, 15.0, 8.400000005960464, 16.0 ] },
"east": { "texture": "#2", "uv": [ 8.0, 15.0, 11.400000005960464, 16.0 ] },
"south": { "texture": "#2", "uv": [ 8.0, 15.0, 11.400000005960464, 16.0 ] },
"west": { "texture": "#2", "uv": [ 7.0, 15.0, 3.4000000059604645, 16.0 ] }
"ground": {
"translation": [0, 4.2, 0],
"scale": [0.4, 0.4, 0.4]
},
"gui": {
"rotation": [42, 135, 32],
"translation": [-1.7, -1.7, 3],
"scale": [0.8, 0.8, 0.8]
},
"fixed": {
"rotation": [0, 90, 0],
"translation": [0, -5, 0]
}
}
]
}

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 628 B

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 631 B

After

Width:  |  Height:  |  Size: 616 B

View file

@ -10,7 +10,7 @@
"item": "create:refined_radiance"
},
"L": {
"tag": "forge:dyes/light_blue"
"tag": "forge:ingots/brass"
},
"O": {
"item": "minecraft:obsidian"

View file

@ -15,7 +15,7 @@
"conditions": [
{
"type": "create:module",
"module": "gardens"
"module": "curiosities"
}
]
}

View file

@ -35,7 +35,7 @@
"conditions": [
{
"type": "create:module",
"module": "gardens"
"module": "curiosities"
}
]
}