Re-Activated the facade recipe and item model
This commit is contained in:
@@ -39,6 +39,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
|||||||
|
|
||||||
import appeng.client.render.cablebus.FacadeBuilder;
|
import appeng.client.render.cablebus.FacadeBuilder;
|
||||||
import appeng.items.parts.ItemFacade;
|
import appeng.items.parts.ItemFacade;
|
||||||
|
import net.minecraftforge.client.model.data.IModelData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This baked model class is used as a dispatcher to redirect the renderer to
|
* This baked model class is used as a dispatcher to redirect the renderer to
|
||||||
@@ -54,27 +55,6 @@ public class FacadeDispatcherBakedModel extends DelegateBakedModel {
|
|||||||
this.facadeBuilder = facadeBuilder;
|
this.facadeBuilder = facadeBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is never used. See the item override list below.
|
|
||||||
@Override
|
|
||||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isGui3d() {
|
|
||||||
return this.getBaseModel().isGui3d();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean func_230044_c_() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isBuiltInRenderer() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemOverrideList getOverrides() {
|
public ItemOverrideList getOverrides() {
|
||||||
return new ItemOverrideList() {
|
return new ItemOverrideList() {
|
||||||
|
|||||||
@@ -18,49 +18,39 @@
|
|||||||
|
|
||||||
package appeng.client.render;
|
package appeng.client.render;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
|
||||||
import net.minecraft.client.renderer.model.IModelTransform;
|
|
||||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
|
||||||
import net.minecraft.client.renderer.model.Material;
|
|
||||||
import net.minecraft.client.renderer.model.ModelBakery;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
import appeng.client.render.cablebus.FacadeBuilder;
|
import appeng.client.render.cablebus.FacadeBuilder;
|
||||||
import appeng.core.AppEng;
|
import appeng.core.AppEng;
|
||||||
|
import com.mojang.datafixers.util.Pair;
|
||||||
|
import net.minecraft.client.renderer.model.*;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.client.model.IModelConfiguration;
|
||||||
|
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The model class for facades. Since facades wrap existing models, they don't
|
* The model class for facades. Since facades wrap existing models, they don't
|
||||||
* declare any dependencies here other than the cable anchor.
|
* declare any dependencies here other than the cable anchor.
|
||||||
*/
|
*/
|
||||||
public class FacadeItemModel implements IUnbakedModel {
|
public class FacadeItemModel implements IModelGeometry<FacadeItemModel> {
|
||||||
|
|
||||||
// We use this to get the default item transforms and make our lives easier
|
// We use this to get the default item transforms and make our lives easier
|
||||||
private static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, "item/facade_base");
|
private static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, "item/facade_base");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<ResourceLocation> getDependencies() {
|
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
|
||||||
return Collections.singleton(MODEL_BASE);
|
IBakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<Material> getTextures(Function<ResourceLocation, IUnbakedModel> modelGetter,
|
|
||||||
Set<Pair<String, String>> missingTextureErrors) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBakedModel bakeModel(ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn,
|
|
||||||
IModelTransform transformIn, ResourceLocation locationIn) {
|
|
||||||
IBakedModel bakedBaseModel = modelBakeryIn.getBakedModel(MODEL_BASE, transformIn, spriteGetterIn);
|
|
||||||
FacadeBuilder facadeBuilder = new FacadeBuilder();
|
FacadeBuilder facadeBuilder = new FacadeBuilder();
|
||||||
|
|
||||||
return new FacadeDispatcherBakedModel(bakedBaseModel, facadeBuilder);
|
return new FacadeDispatcherBakedModel(bakedBaseModel, facadeBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||||
|
return modelGetter.apply(MODEL_BASE).getTextures(modelGetter, missingTextureErrors);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import appeng.client.render.FacadeItemModel;
|
||||||
import com.google.common.base.Stopwatch;
|
import com.google.common.base.Stopwatch;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
@@ -213,6 +214,7 @@ public final class AppEng {
|
|||||||
addBuiltInModel("paint_splotches", PaintSplotchesModel::new);
|
addBuiltInModel("paint_splotches", PaintSplotchesModel::new);
|
||||||
addBuiltInModel("quantum_bridge_formed", QnbFormedModel::new);
|
addBuiltInModel("quantum_bridge_formed", QnbFormedModel::new);
|
||||||
addBuiltInModel("p2p_tunnel_frequency", P2PTunnelFrequencyModel::new);
|
addBuiltInModel("p2p_tunnel_frequency", P2PTunnelFrequencyModel::new);
|
||||||
|
addBuiltInModel("facade", FacadeItemModel::new);
|
||||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "encoded_pattern"),
|
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "encoded_pattern"),
|
||||||
EncodedPatternModelLoader.INSTANCE);
|
EncodedPatternModelLoader.INSTANCE);
|
||||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "part_plane"),
|
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "part_plane"),
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
package appeng.core;
|
package appeng.core;
|
||||||
|
|
||||||
|
import appeng.items.parts.ItemFacade;
|
||||||
|
import appeng.recipes.game.FacadeRecipe;
|
||||||
import net.minecraft.advancements.CriteriaTriggers;
|
import net.minecraft.advancements.CriteriaTriggers;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
@@ -425,8 +427,12 @@ final class Registration {
|
|||||||
GrinderRecipe.TYPE = new AERecipeType<>(GrinderRecipeSerializer.INSTANCE.getRegistryName());
|
GrinderRecipe.TYPE = new AERecipeType<>(GrinderRecipeSerializer.INSTANCE.getRegistryName());
|
||||||
InscriberRecipe.TYPE = new AERecipeType<>(InscriberRecipeSerializer.INSTANCE.getRegistryName());
|
InscriberRecipe.TYPE = new AERecipeType<>(InscriberRecipeSerializer.INSTANCE.getRegistryName());
|
||||||
|
|
||||||
r.registerAll(DisassembleRecipe.SERIALIZER, GrinderRecipeSerializer.INSTANCE, InscriberRecipeSerializer.INSTANCE
|
ItemFacade facadeItem = (ItemFacade) Api.INSTANCE.definitions().items().facade().item();
|
||||||
// FacadeRecipe.getSerializer( (ItemFacade) definitions.items().facade().item() ) FIXME reimplement facades
|
r.registerAll(
|
||||||
|
DisassembleRecipe.SERIALIZER,
|
||||||
|
GrinderRecipeSerializer.INSTANCE,
|
||||||
|
InscriberRecipeSerializer.INSTANCE,
|
||||||
|
FacadeRecipe.getSerializer(facadeItem)
|
||||||
);
|
);
|
||||||
|
|
||||||
CraftingHelper.register(FeaturesEnabled.Serializer.INSTANCE);
|
CraftingHelper.register(FeaturesEnabled.Serializer.INSTANCE);
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import appeng.api.features.AEFeature;
|
|||||||
import appeng.api.util.AEColor;
|
import appeng.api.util.AEColor;
|
||||||
import appeng.api.util.AEColoredItemDefinition;
|
import appeng.api.util.AEColoredItemDefinition;
|
||||||
import appeng.bootstrap.FeatureFactory;
|
import appeng.bootstrap.FeatureFactory;
|
||||||
import appeng.core.CreativeTabFacade;
|
|
||||||
import appeng.core.features.ActivityState;
|
import appeng.core.features.ActivityState;
|
||||||
import appeng.core.features.ColoredItemDefinition;
|
import appeng.core.features.ColoredItemDefinition;
|
||||||
import appeng.core.features.ItemStackSrc;
|
import appeng.core.features.ItemStackSrc;
|
||||||
@@ -51,7 +50,6 @@ import appeng.items.misc.ItemCrystalSeed;
|
|||||||
import appeng.items.misc.ItemEncodedPattern;
|
import appeng.items.misc.ItemEncodedPattern;
|
||||||
import appeng.items.misc.ItemPaintBall;
|
import appeng.items.misc.ItemPaintBall;
|
||||||
import appeng.items.misc.ItemPaintBallRendering;
|
import appeng.items.misc.ItemPaintBallRendering;
|
||||||
import appeng.items.parts.FacadeRendering;
|
|
||||||
import appeng.items.parts.ItemFacade;
|
import appeng.items.parts.ItemFacade;
|
||||||
import appeng.items.storage.BasicItemStorageCell;
|
import appeng.items.storage.BasicItemStorageCell;
|
||||||
import appeng.items.storage.ItemCreativeStorageCell;
|
import appeng.items.storage.ItemCreativeStorageCell;
|
||||||
@@ -277,8 +275,7 @@ public final class ApiItems implements IItems {
|
|||||||
.item("128_cubed_spatial_storage_cell", props -> new ItemSpatialStorageCell(props, 128))
|
.item("128_cubed_spatial_storage_cell", props -> new ItemSpatialStorageCell(props, 128))
|
||||||
.props(storageCellProps).build();
|
.props(storageCellProps).build();
|
||||||
|
|
||||||
this.facade = registry.item("facade", ItemFacade::new).features(AEFeature.FACADES)
|
this.facade = registry.item("facade", ItemFacade::new).features(AEFeature.FACADES).build();
|
||||||
.itemGroup(CreativeTabFacade.instance).rendering(new FacadeRendering()).build();
|
|
||||||
|
|
||||||
this.certusCrystalSeed = registry
|
this.certusCrystalSeed = registry
|
||||||
.item("certus_crystal_seed",
|
.item("certus_crystal_seed",
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of Applied Energistics 2.
|
|
||||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
|
||||||
*
|
|
||||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package appeng.items.parts;
|
|
||||||
|
|
||||||
import appeng.bootstrap.IItemRendering;
|
|
||||||
import appeng.bootstrap.ItemRenderingCustomizer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles rendering customization for facade items. Please note that this works
|
|
||||||
* very differently from actually rendering a Facade in a cable bus.
|
|
||||||
*/
|
|
||||||
public class FacadeRendering extends ItemRenderingCustomizer {
|
|
||||||
@Override
|
|
||||||
public void customize(IItemRendering rendering) {
|
|
||||||
// This actually just uses the path it will look for by default, no custom model
|
|
||||||
// redirection needed
|
|
||||||
// FIXME rendering.builtInModel( "models/item/facade", new FacadeItemModel() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -27,12 +27,9 @@ import net.minecraft.block.BlockState;
|
|||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.*;
|
||||||
import net.minecraft.item.ItemGroup;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.ItemUseContext;
|
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
@@ -58,7 +55,6 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
|||||||
|
|
||||||
public ItemFacade(Properties properties) {
|
public ItemFacade(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
// FIXME this.setHasSubtypes( true );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -98,7 +94,7 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
|||||||
}
|
}
|
||||||
|
|
||||||
Item blockItem = b.asItem();
|
Item blockItem = b.asItem();
|
||||||
if (blockItem != null && blockItem.getGroup() != null) {
|
if (blockItem != Items.AIR && blockItem.getGroup() != null) {
|
||||||
final NonNullList<ItemStack> tmpList = NonNullList.create();
|
final NonNullList<ItemStack> tmpList = NonNullList.create();
|
||||||
b.fillItemGroup(blockItem.getGroup(), tmpList);
|
b.fillItemGroup(blockItem.getGroup(), tmpList);
|
||||||
for (final ItemStack l : tmpList) {
|
for (final ItemStack l : tmpList) {
|
||||||
@@ -116,31 +112,21 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack createFacadeForItem(final ItemStack itemStack, final boolean returnItem) {
|
public ItemStack createFacadeForItem(final ItemStack itemStack, final boolean returnItem) {
|
||||||
if (itemStack.isEmpty()) {
|
if (itemStack.isEmpty() || itemStack.hasTag() || !(itemStack.getItem() instanceof BlockItem)) {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Block block = Block.getBlockFromItem(itemStack.getItem());
|
BlockItem blockItem = (BlockItem) itemStack.getItem();
|
||||||
if (block == Blocks.AIR || itemStack.hasTag()) {
|
Block block = blockItem.getBlock();
|
||||||
|
if (block == Blocks.AIR) {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int metadata = 0; // FIXME itemStack.getItem().getMetadata( itemStack.getDamage() );
|
// We only support the default state for facades. Sorry.
|
||||||
|
BlockState blockState = block.getDefaultState();
|
||||||
|
|
||||||
// Try to get the block state based on the item stack's meta. If this fails,
|
final boolean areTileEntitiesEnabled = false; // FacadeConfig.instance().allowTileEntityFacades();
|
||||||
// don't consider it for a facade
|
final boolean isWhiteListed = true; // FIXME FacadeConfig.instance().isWhiteListed(block);
|
||||||
// This for example fails for Pistons because they hardcoded an invalid meta
|
|
||||||
// value in vanilla
|
|
||||||
BlockState blockState;
|
|
||||||
try {
|
|
||||||
blockState = null; // FIXME block.getStateFromMeta( metadata );
|
|
||||||
} catch (Exception e) {
|
|
||||||
AELog.debug(e, "Cannot create a facade for " + block.getRegistryName());
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
final boolean areTileEntitiesEnabled = FacadeConfig.instance().allowTileEntityFacades();
|
|
||||||
final boolean isWhiteListed = FacadeConfig.instance().isWhiteListed(block, metadata);
|
|
||||||
final boolean isModel = blockState.getRenderType() == BlockRenderType.MODEL;
|
final boolean isModel = blockState.getRenderType() == BlockRenderType.MODEL;
|
||||||
|
|
||||||
final BlockState defaultState = block.getDefaultState();
|
final BlockState defaultState = block.getDefaultState();
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public final class FacadeRecipe extends SpecialRecipe {
|
|||||||
public static IRecipeSerializer<FacadeRecipe> getSerializer(ItemFacade facade) {
|
public static IRecipeSerializer<FacadeRecipe> getSerializer(ItemFacade facade) {
|
||||||
if (SERIALIZER == null) {
|
if (SERIALIZER == null) {
|
||||||
SERIALIZER = new SpecialRecipeSerializer<>(id -> new FacadeRecipe(id, facade));
|
SERIALIZER = new SpecialRecipeSerializer<>(id -> new FacadeRecipe(id, facade));
|
||||||
SERIALIZER.setRegistryName(new ResourceLocation(AppEng.MOD_ID, "facade_recipe"));
|
SERIALIZER.setRegistryName(new ResourceLocation(AppEng.MOD_ID, "facade"));
|
||||||
}
|
}
|
||||||
return SERIALIZER;
|
return SERIALIZER;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"loader": "appliedenergistics2:facade"
|
||||||
|
}
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"conditions": {
|
|
||||||
"material_exists": "appeng.recipes.factories.conditions.MaterialExists",
|
|
||||||
"features": "appeng.recipes.factories.conditions.Features"
|
|
||||||
},
|
|
||||||
"ingredients": {
|
|
||||||
"part": "appeng.recipes.factories.ingredients.PartIngredientFactory"
|
|
||||||
},
|
|
||||||
"recipes": {
|
|
||||||
"part_shaped": "appeng.recipes.factories.recipes.PartRecipeFactory",
|
|
||||||
"part_shapeless": "appeng.recipes.factories.recipes.PartRecipeFactory"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"type": "appliedenergistics2:facade"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user