Rendering/Model Fixes
This commit is contained in:
@@ -9,6 +9,7 @@ import appeng.client.gui.implementations.*;
|
||||
import appeng.client.render.SimpleModelLoader;
|
||||
import appeng.client.render.cablebus.CableBusModelLoader;
|
||||
import appeng.client.render.effects.*;
|
||||
import appeng.client.render.model.DriveModel;
|
||||
import appeng.client.render.model.SkyCompassModel;
|
||||
import appeng.client.render.spatial.SpatialPylonModel;
|
||||
import appeng.client.render.tesr.InscriberTESR;
|
||||
@@ -241,10 +242,10 @@ public final class AppEngClient extends AppEngBase {
|
||||
// FIXME FABRIC addBuiltInModel("glass", GlassModel::new);
|
||||
addBuiltInModel("block/sky_compass", SkyCompassModel::new);
|
||||
addBuiltInModel("item/sky_compass", SkyCompassModel::new);
|
||||
// FIXME FABRIC addBuiltInModel("dummy_fluid_item", DummyFluidItemModel::new);
|
||||
// FIXME FABRIC addBuiltInModel("item/dummy_fluid_item", DummyFluidItemModel::new);
|
||||
// FIXME FABRIC addBuiltInModel("memory_card", MemoryCardModel::new);
|
||||
// FIXME FABRIC addBuiltInModel("biometric_card", BiometricCardModel::new);
|
||||
// FIXME FABRIC addBuiltInModel("drive", DriveModel::new);
|
||||
addBuiltInModel("block/drive", DriveModel::new);
|
||||
// FIXME FABRIC addBuiltInModel("color_applicator", ColorApplicatorModel::new);
|
||||
addBuiltInModel("block/spatial_pylon", SpatialPylonModel::new);
|
||||
// FIXME FABRIC addBuiltInModel("paint_splotches", PaintSplotchesModel::new);
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.renderer.v1.mesh.MutableQuadView;
|
||||
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
|
||||
import net.fabricmc.fabric.impl.client.indigo.renderer.mesh.MutableQuadViewImpl;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Quaternion;
|
||||
|
||||
@@ -18,15 +18,11 @@
|
||||
|
||||
package appeng.client.render.effects;
|
||||
|
||||
import net.minecraft.client.particle.*;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.particle.IAnimatedSprite;
|
||||
import net.minecraft.client.particle.IParticleFactory;
|
||||
import net.minecraft.client.particle.IParticleRenderType;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.particle.SpriteTexturedParticle;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, 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.client.render.model;
|
||||
|
||||
import appeng.block.storage.DriveSlotsState;
|
||||
import net.fabricmc.fabric.api.renderer.v1.Renderer;
|
||||
import net.fabricmc.fabric.api.renderer.v1.RendererAccess;
|
||||
import net.fabricmc.fabric.api.renderer.v1.mesh.Mesh;
|
||||
import net.fabricmc.fabric.api.renderer.v1.mesh.MeshBuilder;
|
||||
import net.fabricmc.fabric.api.renderer.v1.mesh.MutableQuadView;
|
||||
import net.fabricmc.fabric.api.renderer.v1.mesh.QuadEmitter;
|
||||
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
|
||||
import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel;
|
||||
import net.fabricmc.fabric.api.renderer.v1.model.ModelHelper;
|
||||
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
|
||||
import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachedBlockView;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.BlockRenderView;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class DriveBakedModel extends ForwardingBakedModel implements FabricBakedModel {
|
||||
private final Map<Item, BakedModel> cellModels;
|
||||
private final Map<Item, Mesh> bakedCells;
|
||||
private final BakedModel defaultCellModel;
|
||||
private final Mesh defaultCell;
|
||||
|
||||
private final RenderContext.QuadTransform[] slotTransforms;
|
||||
|
||||
public DriveBakedModel(BakedModel bakedBase, Map<Item, BakedModel> cellModels, BakedModel defaultCell) {
|
||||
this.wrapped = bakedBase;
|
||||
this.defaultCellModel = defaultCell;
|
||||
this.defaultCell = convertCellModel(defaultCell);
|
||||
this.slotTransforms = buildSlotTransforms();
|
||||
this.bakedCells = convertCellModels(cellModels);
|
||||
this.cellModels = cellModels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the origin of a drive slot for positioning a cell model into it.
|
||||
*/
|
||||
public static void getSlotOrigin(int row, int col, Vector3f translation) {
|
||||
// Position this drive model copy at the correct slot. The transform is based on
|
||||
// the cell-model being in slot 0,0,0 while the upper left slot's origin is at
|
||||
// 9,13,1
|
||||
float xOffset = (9 - col * 8) / 16.0f;
|
||||
float yOffset = (13 - row * 3) / 16.0f;
|
||||
float zOffset = 1 / 16.0f;
|
||||
translation.set(xOffset, yOffset, zOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext context) {
|
||||
|
||||
super.emitBlockQuads(blockView, state, pos, randomSupplier, context);
|
||||
|
||||
// Add cell models on top of the base model, if possible
|
||||
DriveSlotsState slotsState = getDriveSlotsState(blockView, pos);
|
||||
if (slotsState != null) {
|
||||
for (int row = 0; row < 5; row++) {
|
||||
for (int col = 0; col < 2; col++) {
|
||||
int slot = getSlotIndex(row, col);
|
||||
|
||||
// Add the cell chassis
|
||||
Item cell = slotsState.getCell(slot);
|
||||
BakedModel cellChassisModel = getCellChassisModel(cell);
|
||||
|
||||
context.pushTransform(slotTransforms[slot]);
|
||||
context.fallbackConsumer().accept(cellChassisModel);
|
||||
context.meshConsumer().accept(getCellChassisMesh(cell));
|
||||
context.popTransform();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static DriveSlotsState getDriveSlotsState(BlockRenderView blockView, BlockPos pos) {
|
||||
if (!(blockView instanceof RenderAttachedBlockView)) {
|
||||
return null;
|
||||
}
|
||||
Object attachedData = ((RenderAttachedBlockView) blockView).getBlockEntityRenderAttachment(pos);
|
||||
if (!(attachedData instanceof DriveModelData)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ((DriveModelData) attachedData).getSlotsState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAmbientOcclusion() {
|
||||
// We have faces inside the chassis that are facing east, but should not receive
|
||||
// ambient occlusion from the east-side, but sadly this cannot be fine-tuned on
|
||||
// a face-by-face basis.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine which drive chassis to show based on the used cell
|
||||
public Mesh getCellChassisMesh(Item cell) {
|
||||
if (cell == null) {
|
||||
return bakedCells.get(Items.AIR);
|
||||
}
|
||||
final Mesh model = bakedCells.get(cell);
|
||||
|
||||
return model != null ? model : defaultCell;
|
||||
}
|
||||
|
||||
public BakedModel getCellChassisModel(Item cell) {
|
||||
if (cell == null) {
|
||||
return cellModels.get(Items.AIR);
|
||||
}
|
||||
final BakedModel model = cellModels.get(cell);
|
||||
|
||||
return model != null ? model : defaultCellModel;
|
||||
}
|
||||
|
||||
private RenderContext.QuadTransform[] buildSlotTransforms() {
|
||||
RenderContext.QuadTransform[] result = new RenderContext.QuadTransform[5 * 2];
|
||||
|
||||
for (int row = 0; row < 5; row++) {
|
||||
for (int col = 0; col < 2; col++) {
|
||||
|
||||
Vector3f translation = new Vector3f();
|
||||
getSlotOrigin(row, col, translation);
|
||||
|
||||
result[getSlotIndex(row, col)] = new QuadTranslator(translation.getX(), translation.getY(), translation.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int getSlotIndex(int row, int col) {
|
||||
return row * 2 + col;
|
||||
}
|
||||
|
||||
private static class QuadTranslator implements RenderContext.QuadTransform {
|
||||
private final float x;
|
||||
private final float y;
|
||||
private final float z;
|
||||
|
||||
public QuadTranslator(float x, float y, float z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean transform(MutableQuadView quad) {
|
||||
Vector3f target = new Vector3f();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
quad.copyPos(i, target);
|
||||
target.add(x, y, z);
|
||||
quad.pos(i, target);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<Item, Mesh> convertCellModels(Map<Item, BakedModel> cellModels) {
|
||||
Map<Item, Mesh> result = new IdentityHashMap<>();
|
||||
|
||||
for (Map.Entry<Item, BakedModel> entry : cellModels.entrySet()) {
|
||||
result.put(entry.getKey(), convertCellModel(entry.getValue()));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Mesh convertCellModel(BakedModel bakedModel) {
|
||||
Renderer renderer = RendererAccess.INSTANCE.getRenderer();
|
||||
Random random = new Random();
|
||||
MeshBuilder meshBuilder = renderer.meshBuilder();
|
||||
QuadEmitter emitter = meshBuilder.getEmitter();
|
||||
emitter.material(renderer.materialFinder().disableDiffuse(0, false).disableAo(0, true).find());
|
||||
|
||||
for (int i = 0; i <= ModelHelper.NULL_FACE_ID; i++) {
|
||||
Direction face = ModelHelper.faceFromIndex(i);
|
||||
List<BakedQuad> quads = bakedModel.getQuads(null, face, random);
|
||||
for (BakedQuad quad : quads) {
|
||||
emitter.fromVanilla(quad.getVertexData(), 0, false);
|
||||
emitter.cullFace(face);
|
||||
emitter.nominalFace(face);
|
||||
emitter.emit();
|
||||
}
|
||||
}
|
||||
return meshBuilder.build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, 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.client.render.model;
|
||||
|
||||
import appeng.api.client.ICellModelRegistry;
|
||||
import appeng.client.render.BasicUnbakedModel;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.api.client.ApiCellModelRegistry;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.ModelBakeSettings;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class DriveModel implements BasicUnbakedModel {
|
||||
|
||||
private static final Identifier MODEL_BASE = new Identifier(
|
||||
"appliedenergistics2:block/drive/drive_base");
|
||||
private static final Identifier MODEL_CELL_EMPTY = new Identifier(
|
||||
"appliedenergistics2:block/drive/drive_cell_empty");
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BakedModel bake(ModelLoader loader, Function<SpriteIdentifier, Sprite> textureGetter, ModelBakeSettings rotationContainer, Identifier modelId) {
|
||||
final ICellModelRegistry cellRegistry = Api.instance().client().cells();
|
||||
final Map<Item, BakedModel> cellModels = new IdentityHashMap<>();
|
||||
|
||||
// Load the base model and the model for each cell model.
|
||||
for (Entry<Item, Identifier> entry : cellRegistry.models().entrySet()) {
|
||||
BakedModel cellModel = loader.bake(entry.getValue(), rotationContainer);
|
||||
cellModels.put(entry.getKey(), cellModel);
|
||||
}
|
||||
|
||||
final BakedModel baseModel = loader.bake(MODEL_BASE, rotationContainer);
|
||||
final BakedModel defaultCell = loader.bake(cellRegistry.getDefaultModel(), rotationContainer);
|
||||
cellModels.put(Items.AIR, loader.bake(MODEL_CELL_EMPTY, rotationContainer));
|
||||
|
||||
return new DriveBakedModel(baseModel, cellModels, defaultCell);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Identifier> getModelDependencies() {
|
||||
ICellModelRegistry cells = Api.instance().client().cells();
|
||||
return ImmutableSet.<Identifier>builder()
|
||||
.add(cells.getDefaultModel())
|
||||
.addAll(ApiCellModelRegistry.getModels())
|
||||
.addAll(cells.models().values())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,15 +2,13 @@ package appeng.client.render.tesr;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import appeng.block.storage.DriveSlotState;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexFormats;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
|
||||
/**
|
||||
* Utility class to render LEDs for storage cells from a Tile Entity Renderer.
|
||||
@@ -53,11 +51,11 @@ class CellLedRenderer {
|
||||
// Bottom Face
|
||||
R, B, FR, L, B, FR, L, B, BA, R, B, BA, };
|
||||
|
||||
public static final RenderType RENDER_LAYER = RenderType.makeType("ae_drive_leds",
|
||||
DefaultVertexFormats.POSITION_COLOR, 7, 32565, false, true, RenderType.State.getBuilder().build(false));
|
||||
public static final RenderLayer RENDER_LAYER = RenderLayer.of("ae_drive_leds",
|
||||
VertexFormats.POSITION_COLOR, 7, 32565, false, true, RenderLayer.MultiPhaseParameters.builder().build(false));
|
||||
|
||||
public static void renderLed(IChestOrDrive drive, int slot, IVertexBuilder buffer, MatrixStack ms,
|
||||
float partialTicks) {
|
||||
public static void renderLed(IChestOrDrive drive, int slot, VertexConsumer buffer, MatrixStack ms,
|
||||
float partialTicks) {
|
||||
|
||||
Vector3f color = getColorForSlot(drive, slot, partialTicks);
|
||||
if (color == null) {
|
||||
@@ -68,8 +66,8 @@ class CellLedRenderer {
|
||||
float x = LED_QUADS[i];
|
||||
float y = LED_QUADS[i + 1];
|
||||
float z = LED_QUADS[i + 2];
|
||||
buffer.pos(ms.getLast().getMatrix(), x, y, z).color(color.getX(), color.getY(), color.getZ(), 1.f)
|
||||
.endVertex();
|
||||
buffer.vertex(ms.peek().getModel(), x, y, z).color(color.getX(), color.getY(), color.getZ(), 1.f)
|
||||
.next();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,56 +25,57 @@ import java.util.Random;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import appeng.client.render.BakedModelUnwrapper;
|
||||
import appeng.client.render.model.AutoRotatingBakedModel;
|
||||
import appeng.client.render.model.DriveBakedModel;
|
||||
import appeng.tile.storage.ChestBlockEntity;
|
||||
import net.fabricmc.fabric.api.renderer.v1.mesh.Mesh;
|
||||
import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockModelRenderer;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.block.BlockModelRenderer;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.BakedModelManager;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import appeng.api.client.ICellModelRegistry;
|
||||
import appeng.block.storage.DriveSlotsState;
|
||||
import appeng.client.render.DelegateBakedModel;
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.core.Api;
|
||||
import appeng.tile.storage.ChestTileEntity;
|
||||
|
||||
/**
|
||||
* The tile entity renderer for ME chests takes care of rendering the right
|
||||
* model for the inserted cell, as well as the LED.
|
||||
*/
|
||||
public class ChestTileEntityRenderer extends TileEntityRenderer<ChestTileEntity> {
|
||||
public class ChestTileEntityRenderer extends BlockEntityRenderer<ChestBlockEntity> {
|
||||
|
||||
private final ICellModelRegistry cellModelRegistry = Api.instance().client().cells();
|
||||
|
||||
private final ModelManager modelManager;
|
||||
private final BakedModelManager modelManager;
|
||||
|
||||
private final BlockModelRenderer blockRenderer;
|
||||
|
||||
public ChestTileEntityRenderer(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
Minecraft client = Minecraft.getInstance();
|
||||
modelManager = client.getModelManager();
|
||||
blockRenderer = client.getBlockRendererDispatcher().getBlockModelRenderer();
|
||||
public ChestTileEntityRenderer(BlockEntityRenderDispatcher renderDispatcher) {
|
||||
super(renderDispatcher);
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
modelManager = client.getBakedModelManager();
|
||||
blockRenderer = client.getBlockRenderManager().getModelRenderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(ChestTileEntity chest, float partialTicks, MatrixStack matrices, IRenderTypeBuffer buffers,
|
||||
int combinedLight, int combinedOverlay) {
|
||||
public void render(ChestBlockEntity chest, float partialTicks, MatrixStack matrices, VertexConsumerProvider buffers,
|
||||
int combinedLight, int combinedOverlay) {
|
||||
|
||||
World world = chest.getWorld();
|
||||
if (world == null) {
|
||||
@@ -88,12 +89,12 @@ public class ChestTileEntityRenderer extends TileEntityRenderer<ChestTileEntity>
|
||||
return; // No cell inserted into chest
|
||||
}
|
||||
|
||||
ResourceLocation cellModelLocation = cellModelRegistry.model(cellItem);
|
||||
if (cellModelLocation == null) {
|
||||
cellModelLocation = cellModelRegistry.getDefaultModel();
|
||||
// Try to get the right cell chassis model from the drive model since it already loads them all
|
||||
DriveBakedModel driveModel = getDriveModel();
|
||||
if (driveModel == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IBakedModel model = modelManager.getModel(cellModelLocation);
|
||||
BakedModel cellModel = driveModel.getCellChassisModel(cellItem);
|
||||
|
||||
matrices.push();
|
||||
matrices.translate(0.5, 0.5, 0.5);
|
||||
@@ -106,45 +107,49 @@ public class ChestTileEntityRenderer extends TileEntityRenderer<ChestTileEntity>
|
||||
matrices.translate(5 / 16.0, 4 / 16.0, 0);
|
||||
|
||||
// Render the cell model as-if it was a block model
|
||||
IVertexBuilder buffer = buffers.getBuffer(RenderType.getCutout());
|
||||
VertexConsumer buffer = buffers.getBuffer(RenderLayer.getCutout());
|
||||
// We "fake" the position here to make it use the light-value in front of the
|
||||
// drive
|
||||
FaceRotatingModel rotatedModel = new FaceRotatingModel(model, rotation);
|
||||
blockRenderer.renderModel(world, rotatedModel, chest.getBlockState(), chest.getPos(), matrices, buffer, false,
|
||||
new Random(), 0L, combinedOverlay, EmptyModelData.INSTANCE);
|
||||
BakedModel rotatedModel = new FaceRotatingModel(cellModel, rotation);
|
||||
blockRenderer.render(world, rotatedModel, chest.getCachedState(), chest.getPos(), matrices, buffer, false,
|
||||
new Random(), 0L, combinedOverlay);
|
||||
|
||||
IVertexBuilder ledBuffer = buffers.getBuffer(CellLedRenderer.RENDER_LAYER);
|
||||
VertexConsumer ledBuffer = buffers.getBuffer(CellLedRenderer.RENDER_LAYER);
|
||||
CellLedRenderer.renderLed(chest, 0, ledBuffer, matrices, partialTicks);
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
private DriveBakedModel getDriveModel() {
|
||||
BakedModel driveModel = modelManager.getBlockModels().getModel(Api.instance().definitions().blocks().drive().block().getDefaultState());
|
||||
return BakedModelUnwrapper.unwrap(driveModel, DriveBakedModel.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual vertex data will be transformed using the matrix stack, but the
|
||||
* faces will not be correctly rotated so the incorrect lighting data would be
|
||||
* used to apply diffuse lighting and the lightmap texture.
|
||||
*/
|
||||
private static class FaceRotatingModel extends DelegateBakedModel {
|
||||
private static class FaceRotatingModel extends ForwardingBakedModel {
|
||||
private final FacingToRotation r;
|
||||
|
||||
protected FaceRotatingModel(IBakedModel base, FacingToRotation r) {
|
||||
super(base);
|
||||
protected FaceRotatingModel(BakedModel base, FacingToRotation r) {
|
||||
this.wrapped = base;
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand,
|
||||
@Nonnull IModelData extraData) {
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand) {
|
||||
if (side != null) {
|
||||
side = r.rotate(side); // This fixes the incorrect lightmap position
|
||||
side = r.resultingRotate(side); // This fixes the incorrect lightmap position
|
||||
}
|
||||
List<BakedQuad> quads = new ArrayList<>(super.getQuads(state, side, rand, extraData));
|
||||
List<BakedQuad> quads = new ArrayList<>(super.getQuads(state, side, rand));
|
||||
|
||||
for (int i = 0; i < quads.size(); i++) {
|
||||
BakedQuad quad = quads.get(i);
|
||||
quads.set(i, new BakedQuad(quad.getVertexData(), quad.getTintIndex(), r.rotate(quad.getFace()),
|
||||
quad.func_187508_a(), quad.shouldApplyDiffuseLighting()));
|
||||
quads.set(i, new BakedQuad(quad.getVertexData(), quad.getColorIndex(), r.rotate(quad.getFace()),
|
||||
/* FIXME FABRIC: sprite is protected but unused?? */ null, quad.hasShade()));
|
||||
}
|
||||
|
||||
return quads;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package appeng.client.render.tesr;
|
||||
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import appeng.client.render.model.DriveBakedModel;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexFormats;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
@@ -13,7 +12,6 @@ import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.client.render.model.DriveBakedModel;
|
||||
import appeng.tile.storage.DriveBlockEntity;
|
||||
|
||||
/**
|
||||
@@ -22,8 +20,8 @@ import appeng.tile.storage.DriveBlockEntity;
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEntity> {
|
||||
|
||||
public DriveLedTileEntityRenderer(BlockEntityRendererDispatcher rendererDispatcher) {
|
||||
super(rendererDispatcher);
|
||||
public DriveLedTileEntityRenderer(BlockEntityRenderDispatcher renderDispatcher) {
|
||||
super(renderDispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,6 +28,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.CraftingResultInventory;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.recipe.CraftingRecipe;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.screen.slot.CraftingResultSlot;
|
||||
@@ -101,7 +102,7 @@ public class PatternTermContainer extends MEMonitorableContainer
|
||||
private final RestrictedInputSlot patternSlotOUT;
|
||||
private final ICraftingHelper craftingHelper = Api.INSTANCE.crafting();
|
||||
|
||||
private Recipe<CraftingInventory> currentRecipe;
|
||||
private CraftingRecipe currentRecipe;
|
||||
@GuiSync(97)
|
||||
public boolean craftingMode = true;
|
||||
@GuiSync(96)
|
||||
@@ -242,7 +243,7 @@ public class PatternTermContainer extends MEMonitorableContainer
|
||||
} else {
|
||||
output = craftingHelper.encodeProcessingPattern(output, in, out);
|
||||
}
|
||||
this.patternSlotOUT.putStack(output);
|
||||
this.patternSlotOUT.setStack(output);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2020, 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.core;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.forgespi.language.ModFileScanData;
|
||||
import net.minecraftforge.forgespi.language.ModFileScanData.AnnotationData;
|
||||
|
||||
import appeng.api.AEAddon;
|
||||
import appeng.api.IAEAddon;
|
||||
import appeng.api.IAppEngApi;
|
||||
|
||||
/**
|
||||
* Loads AE addons on startup and provides them with an {@link IAppEngApi}
|
||||
* instance.
|
||||
*/
|
||||
class AddonLoader {
|
||||
|
||||
public static void loadAddons(IAppEngApi api) {
|
||||
final Type annotationType = Type.getType(AEAddon.class);
|
||||
final Collection<ModFileScanData> allScanData = ModList.get().getAllScanData();
|
||||
|
||||
allScanData.stream().map(ModFileScanData::getAnnotations).flatMap(Set::stream)
|
||||
.filter(a -> Objects.equals(a.getAnnotationType(), annotationType)).map(AnnotationData::getMemberName)
|
||||
.forEach(className -> {
|
||||
try {
|
||||
final Class<?> clazz = Class.forName(className);
|
||||
final Class<? extends IAEAddon> instanceClass = clazz.asSubclass(IAEAddon.class);
|
||||
final IAEAddon instance = instanceClass.newInstance();
|
||||
|
||||
instance.onAPIAvailable(api);
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
|
||||
| LinkageError e) {
|
||||
AELog.error("Failed to load: %s", className, e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package appeng.core;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.api.features.IRegistryContainer;
|
||||
import appeng.api.networking.IGridCacheRegistry;
|
||||
@@ -348,7 +348,7 @@ public abstract class AppEngBase implements AppEng {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockState quartzOre = AEApi.instance().definitions().blocks().quartzOre().block().getDefaultState();
|
||||
BlockState quartzOre = Api.instance().definitions().blocks().quartzOre().block().getDefaultState();
|
||||
b.addFeature(GenerationStep.Feature.UNDERGROUND_ORES,
|
||||
Feature.ORE
|
||||
.configure(new OreFeatureConfig(OreFeatureConfig.Target.NATURAL_STONE,
|
||||
@@ -358,7 +358,7 @@ public abstract class AppEngBase implements AppEng {
|
||||
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.CHARGED_CERTUS_ORE)) {
|
||||
|
||||
BlockState chargedQuartzOre = AEApi.instance().definitions().blocks().quartzOreCharged().block()
|
||||
BlockState chargedQuartzOre = Api.instance().definitions().blocks().quartzOreCharged().block()
|
||||
.getDefaultState();
|
||||
b.addFeature(GenerationStep.Feature.UNDERGROUND_DECORATION,
|
||||
ChargedQuartzOreFeature.INSTANCE
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
@@ -39,7 +39,7 @@ public final class CreativeTab {
|
||||
public static void init() {
|
||||
INSTANCE = FabricItemGroupBuilder.create(AppEng.makeId("main"))
|
||||
.icon(() -> {
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IDefinitions definitions = Api.instance().definitions();
|
||||
final IBlocks blocks = definitions.blocks();
|
||||
return blocks.quartzOre().stack(1); // FIXME FABRIC blocks.controller().stack(1);
|
||||
})
|
||||
|
||||
@@ -26,11 +26,11 @@ import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.ICraftingRecipe;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.item.crafting.RecipeManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.recipe.CraftingRecipe;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.recipe.RecipeManager;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.crafting.ICraftingHelper;
|
||||
@@ -64,8 +64,8 @@ public class ApiCrafting implements ICraftingHelper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack encodeCraftingPattern(@Nullable ItemStack stack, ICraftingRecipe recipe, ItemStack[] in,
|
||||
ItemStack out, boolean allowSubstitutes) {
|
||||
public ItemStack encodeCraftingPattern(@Nullable ItemStack stack, CraftingRecipe recipe, ItemStack[] in,
|
||||
ItemStack out, boolean allowSubstitutes) {
|
||||
if (stack == null) {
|
||||
stack = encodedPattern.stack(1);
|
||||
} else {
|
||||
@@ -102,10 +102,10 @@ public class ApiCrafting implements ICraftingHelper {
|
||||
// The recipe ids encoded in a pattern can go stale. This code attempts to find
|
||||
// the new id
|
||||
// based on the stored inputs/outputs if that happens.
|
||||
ResourceLocation recipeId = patternItem.getCraftingRecipeId(is);
|
||||
Identifier recipeId = patternItem.getCraftingRecipeId(is);
|
||||
if (recipeId != null) {
|
||||
IRecipe<?> recipe = world.getRecipeManager().getRecipes(IRecipeType.CRAFTING).get(recipeId);
|
||||
if (!(recipe instanceof ICraftingRecipe)) {
|
||||
Recipe<?> recipe = world.getRecipeManager().getAllOfType(RecipeType.CRAFTING).get(recipeId);
|
||||
if (!(recipe instanceof CraftingRecipe)) {
|
||||
if (!autoRecovery || !attemptRecovery(patternItem, is, world)) {
|
||||
return null;
|
||||
}
|
||||
@@ -128,22 +128,22 @@ public class ApiCrafting implements ICraftingHelper {
|
||||
return false;
|
||||
}
|
||||
|
||||
ResourceLocation currentRecipeId = patternItem.getCraftingRecipeId(itemStack);
|
||||
Identifier currentRecipeId = patternItem.getCraftingRecipeId(itemStack);
|
||||
|
||||
// Fill a crafting inventory with the ingredients to find a suitable recipe
|
||||
CraftingInventory testInventory = new CraftingInventory(new ContainerNull(), 3, 3);
|
||||
for (int x = 0; x < 9; x++) {
|
||||
final IAEItemStack ais = ingredients.get(x);
|
||||
final ItemStack gs = ais != null ? ais.createItemStack() : ItemStack.EMPTY;
|
||||
testInventory.setInventorySlotContents(x, gs);
|
||||
testInventory.setStack(x, gs);
|
||||
}
|
||||
|
||||
ICraftingRecipe potentialRecipe = recipeManager.getRecipe(IRecipeType.CRAFTING, testInventory, world)
|
||||
CraftingRecipe potentialRecipe = recipeManager.getFirstMatch(RecipeType.CRAFTING, testInventory, world)
|
||||
.orElse(null);
|
||||
|
||||
if (potentialRecipe != null) {
|
||||
// Check that it matches the expected output
|
||||
if (products.get(0).isSameType(potentialRecipe.getCraftingResult(testInventory))) {
|
||||
if (products.get(0).isSameType(potentialRecipe.craft(testInventory))) {
|
||||
// Yay we found a match, reencode the pattern
|
||||
AELog.debug("Re-Encoding pattern from %s -> %s", currentRecipeId, potentialRecipe.getId());
|
||||
ItemStack[] in = ingredients.stream().map(ais -> ais != null ? ais.createItemStack() : ItemStack.EMPTY)
|
||||
|
||||
@@ -19,10 +19,9 @@
|
||||
|
||||
package appeng.core.api.client;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -30,48 +29,47 @@ import javax.annotation.Nullable;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
|
||||
import appeng.api.client.ICellModelRegistry;
|
||||
import appeng.core.ApiDefinitions;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class ApiCellModelRegistry implements ICellModelRegistry {
|
||||
|
||||
private static final ResourceLocation MODEL_BASE = new ResourceLocation(
|
||||
private static final Identifier MODEL_BASE = new Identifier(
|
||||
"appliedenergistics2:block/drive/drive_base");
|
||||
private static final ResourceLocation MODEL_CELL_EMPTY = new ResourceLocation(
|
||||
private static final Identifier MODEL_CELL_EMPTY = new Identifier(
|
||||
"appliedenergistics2:block/drive/drive_cell_empty");
|
||||
private static final ResourceLocation MODEL_CELL_DEFAULT = new ResourceLocation(
|
||||
private static final Identifier MODEL_CELL_DEFAULT = new Identifier(
|
||||
"appliedenergistics2:block/drive/drive_cell");
|
||||
private static final ResourceLocation MODEL_CELL_ITEMS_1K = new ResourceLocation(
|
||||
private static final Identifier MODEL_CELL_ITEMS_1K = new Identifier(
|
||||
"appliedenergistics2:block/drive/cells/1k_item_cell");
|
||||
private static final ResourceLocation MODEL_CELL_ITEMS_4K = new ResourceLocation(
|
||||
private static final Identifier MODEL_CELL_ITEMS_4K = new Identifier(
|
||||
"appliedenergistics2:block/drive/cells/4k_item_cell");
|
||||
private static final ResourceLocation MODEL_CELL_ITEMS_16K = new ResourceLocation(
|
||||
private static final Identifier MODEL_CELL_ITEMS_16K = new Identifier(
|
||||
"appliedenergistics2:block/drive/cells/16k_item_cell");
|
||||
private static final ResourceLocation MODEL_CELL_ITEMS_64K = new ResourceLocation(
|
||||
private static final Identifier MODEL_CELL_ITEMS_64K = new Identifier(
|
||||
"appliedenergistics2:block/drive/cells/64k_item_cell");
|
||||
private static final ResourceLocation MODEL_CELL_FLUIDS_1K = new ResourceLocation(
|
||||
private static final Identifier MODEL_CELL_FLUIDS_1K = new Identifier(
|
||||
"appliedenergistics2:block/drive/cells/1k_fluid_cell");
|
||||
private static final ResourceLocation MODEL_CELL_FLUIDS_4K = new ResourceLocation(
|
||||
private static final Identifier MODEL_CELL_FLUIDS_4K = new Identifier(
|
||||
"appliedenergistics2:block/drive/cells/4k_fluid_cell");
|
||||
private static final ResourceLocation MODEL_CELL_FLUIDS_16K = new ResourceLocation(
|
||||
private static final Identifier MODEL_CELL_FLUIDS_16K = new Identifier(
|
||||
"appliedenergistics2:block/drive/cells/16k_fluid_cell");
|
||||
private static final ResourceLocation MODEL_CELL_FLUIDS_64K = new ResourceLocation(
|
||||
private static final Identifier MODEL_CELL_FLUIDS_64K = new Identifier(
|
||||
"appliedenergistics2:block/drive/cells/64k_fluid_cell");
|
||||
private static final ResourceLocation MODEL_CELL_CREATIVE = new ResourceLocation(
|
||||
private static final Identifier MODEL_CELL_CREATIVE = new Identifier(
|
||||
"appliedenergistics2:block/drive/cells/creative_cell");
|
||||
|
||||
private static final ResourceLocation[] MODELS = { MODEL_BASE, MODEL_CELL_EMPTY, MODEL_CELL_DEFAULT,
|
||||
private static final Identifier[] MODELS = { MODEL_BASE, MODEL_CELL_EMPTY, MODEL_CELL_DEFAULT,
|
||||
MODEL_CELL_ITEMS_1K, MODEL_CELL_ITEMS_4K, MODEL_CELL_ITEMS_16K, MODEL_CELL_ITEMS_64K, MODEL_CELL_FLUIDS_1K,
|
||||
MODEL_CELL_FLUIDS_4K, MODEL_CELL_FLUIDS_16K, MODEL_CELL_FLUIDS_64K, MODEL_CELL_CREATIVE };
|
||||
|
||||
public static void registerModels() {
|
||||
Arrays.stream(MODELS).forEach(ModelLoader::addSpecialModel);
|
||||
public static Collection<Identifier> getModels() {
|
||||
return Arrays.asList(MODELS);
|
||||
}
|
||||
|
||||
private final Map<Item, ResourceLocation> registry;
|
||||
private final Map<Item, Identifier> registry;
|
||||
|
||||
public ApiCellModelRegistry(ApiDefinitions definitions) {
|
||||
this.registry = new IdentityHashMap<>();
|
||||
@@ -88,7 +86,7 @@ public class ApiCellModelRegistry implements ICellModelRegistry {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerModel(Item item, ResourceLocation model) {
|
||||
public void registerModel(Item item, Identifier model) {
|
||||
Preconditions.checkNotNull(item);
|
||||
Preconditions.checkNotNull(model);
|
||||
Preconditions.checkArgument(!this.registry.containsKey(item), "Cannot register an item twice.");
|
||||
@@ -98,7 +96,7 @@ public class ApiCellModelRegistry implements ICellModelRegistry {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ResourceLocation model(@Nonnull Item item) {
|
||||
public Identifier model(@Nonnull Item item) {
|
||||
Preconditions.checkNotNull(item);
|
||||
|
||||
return this.registry.get(item);
|
||||
@@ -106,13 +104,13 @@ public class ApiCellModelRegistry implements ICellModelRegistry {
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public Map<Item, ResourceLocation> models() {
|
||||
public Map<Item, Identifier> models() {
|
||||
return Collections.unmodifiableMap(this.registry);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ResourceLocation getDefaultModel() {
|
||||
public Identifier getDefaultModel() {
|
||||
return MODEL_CELL_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
@@ -364,10 +364,10 @@ public final class ApiBlocks implements IBlocks {
|
||||
.rendering(new DriveRendering()).build();
|
||||
this.chest = registry.block("chest", ChestBlock::new).features(AEFeature.STORAGE_CELLS, AEFeature.ME_CHEST)
|
||||
.tileEntity(registry.tileEntity("chest", ChestBlockEntity.class, ChestBlockEntity::new)
|
||||
.rendering(new TileEntityRenderingCustomizer<ChestTileEntity>() {
|
||||
.rendering(new TileEntityRenderingCustomizer<ChestBlockEntity>() {
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void customize(TileEntityRendering<ChestTileEntity> rendering) {
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void customize(TileEntityRendering<ChestBlockEntity> rendering) {
|
||||
rendering.tileEntityRenderer(ChestTileEntityRenderer::new);
|
||||
}
|
||||
}).build())
|
||||
|
||||
@@ -65,7 +65,6 @@ import appeng.parts.networking.GlassCablePart;
|
||||
import appeng.parts.networking.QuartzFiberPart;
|
||||
import appeng.parts.networking.SmartCablePart;
|
||||
import appeng.parts.networking.SmartDenseCablePart;
|
||||
import appeng.parts.p2p.FEP2PTunnelPart;
|
||||
import appeng.parts.p2p.FluidP2PTunnelPart;
|
||||
import appeng.parts.p2p.ItemP2PTunnelPart;
|
||||
import appeng.parts.p2p.LightP2PTunnelPart;
|
||||
|
||||
@@ -26,10 +26,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.api.exceptions.AppEngException;
|
||||
import appeng.api.movable.IMovableHandler;
|
||||
@@ -38,11 +35,14 @@ import appeng.api.movable.IMovableTile;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.spatial.DefaultSpatialHandler;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class MovableTileRegistry implements IMovableRegistry {
|
||||
|
||||
private static final ResourceLocation TAG_WHITELIST = new ResourceLocation(AppEng.MOD_ID, "spatial/whitelist");
|
||||
private static final ResourceLocation TAG_BLACKLIST = new ResourceLocation(AppEng.MOD_ID, "spatial/blacklist");
|
||||
private static final Identifier TAG_WHITELIST = new Identifier(AppEng.MOD_ID, "spatial/whitelist");
|
||||
private static final Identifier TAG_BLACKLIST = new Identifier(AppEng.MOD_ID, "spatial/blacklist");
|
||||
|
||||
private final Set<Block> blacklisted = new HashSet<>();
|
||||
|
||||
@@ -55,8 +55,8 @@ public class MovableTileRegistry implements IMovableRegistry {
|
||||
private final Tag<Block> blockTagBlackList;
|
||||
|
||||
public MovableTileRegistry() {
|
||||
this.blockTagWhiteList = BlockTags.getCollection().getOrCreate(TAG_WHITELIST);
|
||||
this.blockTagBlackList = BlockTags.getCollection().getOrCreate(TAG_BLACKLIST);
|
||||
this.blockTagWhiteList = BlockTags.getContainer().getOrCreate(TAG_WHITELIST);
|
||||
this.blockTagBlackList = BlockTags.getContainer().getOrCreate(TAG_BLACKLIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,7 +120,7 @@ public class MovableTileRegistry implements IMovableRegistry {
|
||||
|
||||
// if the block itself is via block tags
|
||||
if (AEConfig.instance().getSpatialBlockTags()
|
||||
&& this.blockTagWhiteList.contains(te.getBlockState().getBlock())) {
|
||||
&& this.blockTagWhiteList.contains(te.getCachedState().getBlock())) {
|
||||
this.valid.put(myClass, this.dsh);
|
||||
return this.dsh;
|
||||
}
|
||||
|
||||
@@ -20,10 +20,6 @@ package appeng.core.features.registries;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
|
||||
import appeng.api.features.IWorldGen;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
@@ -101,7 +101,7 @@ public class BlockTransitionEffectPacket extends BasePacket {
|
||||
playBreakOrPickupSound();
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Environment(EnvType.CLIENT)
|
||||
private void spawnParticles() {
|
||||
|
||||
EnergyParticleData data = new EnergyParticleData(false, direction);
|
||||
@@ -120,7 +120,7 @@ public class BlockTransitionEffectPacket extends BasePacket {
|
||||
}
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Environment(EnvType.CLIENT)
|
||||
private void playBreakOrPickupSound() {
|
||||
|
||||
SoundEvent soundEvent;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package appeng.crafting;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
|
||||
@@ -30,14 +30,12 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
@@ -58,9 +56,9 @@ public class ReplicatorCardItem extends AEBaseItem implements AEToolItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
|
||||
if (!worldIn.isRemote()) {
|
||||
final CompoundNBT tag = playerIn.getHeldItem(handIn).getOrCreateTag();
|
||||
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
|
||||
if (!world.isClient()) {
|
||||
final CompoundTag tag = user.getStackInHand(hand).getOrCreateTag();
|
||||
final int replications;
|
||||
|
||||
if (tag.contains("r")) {
|
||||
@@ -71,10 +69,10 @@ public class ReplicatorCardItem extends AEBaseItem implements AEToolItem {
|
||||
|
||||
tag.putInt("r", replications);
|
||||
|
||||
playerIn.sendMessage(new StringTextComponent((replications + 1) + "³ Replications"));
|
||||
user.sendMessage(new LiteralText((replications + 1) + "³ Replications"), true);
|
||||
}
|
||||
|
||||
return super.onItemRightClick(worldIn, playerIn, handIn);
|
||||
return super.use(world, user, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,9 +152,9 @@ public class ReplicatorCardItem extends AEBaseItem implements AEToolItem {
|
||||
final int min_z = min.z;
|
||||
|
||||
// Invert to maintain correct sign for west/east
|
||||
final int x_rot = (int) -Math.signum(MathHelper.wrapDegrees(player.rotationYaw));
|
||||
final int x_rot = (int) -Math.signum(MathHelper.wrapDegrees(player.yaw));
|
||||
// Rotate by 90 degree, so north/south are negative/positive
|
||||
final int z_rot = (int) Math.signum(MathHelper.wrapDegrees(player.rotationYaw + 90));
|
||||
final int z_rot = (int) Math.signum(MathHelper.wrapDegrees(player.yaw + 90));
|
||||
|
||||
// Loops for replication in each direction
|
||||
for (int r_x = 0; r_x < replications; r_x++) {
|
||||
|
||||
@@ -25,9 +25,12 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.tag.ItemTags;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -39,7 +42,7 @@ import appeng.util.Platform;
|
||||
|
||||
public final class SingularityEntity extends AEBaseItemEntity {
|
||||
|
||||
private static final ResourceLocation TAG_ENDER_PEARL = new ResourceLocation("forge:ender_pearls");
|
||||
private static final Identifier TAG_ENDER_PEARL = new Identifier("c:ender_pearls");
|
||||
|
||||
public static EntityType<SingularityEntity> TYPE;
|
||||
|
||||
@@ -93,7 +96,8 @@ public final class SingularityEntity extends AEBaseItemEntity {
|
||||
|
||||
// check... other name.
|
||||
if (!matches) {
|
||||
if (other.getItem().getTags().contains(TAG_ENDER_PEARL)) {
|
||||
Tag<Item> tag = ItemTags.getContainer().get(TAG_ENDER_PEARL);
|
||||
if (tag != null && other.getItem().isIn(tag)) {
|
||||
matches = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package appeng.entity;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.sync.packets.ICustomEntity;
|
||||
@@ -100,7 +100,7 @@ public final class TinyTNTPrimedEntity extends TntEntity implements ICustomEntit
|
||||
this.updateWaterState();
|
||||
if (this.isSubmergedInWater() && Platform.isServer()) // put out the fuse.
|
||||
{
|
||||
AEApi.instance().definitions().blocks().tinyTNT().maybeStack(1).ifPresent(tntStack -> {
|
||||
Api.instance().definitions().blocks().tinyTNT().maybeStack(1).ifPresent(tntStack -> {
|
||||
final ItemEntity item = new ItemEntity(this.world, this.getX(), this.getY(), this.getZ(),
|
||||
tntStack);
|
||||
|
||||
|
||||
@@ -52,7 +52,6 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.fluids.util.AEFluidInventory;
|
||||
|
||||
@@ -4,7 +4,7 @@ package appeng.fluids.parts;
|
||||
import alexiil.mc.lib.attributes.Simulation;
|
||||
import alexiil.mc.lib.attributes.fluid.amount.FluidAmount;
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.IncludeExclude;
|
||||
|
||||
@@ -23,7 +23,7 @@ import alexiil.mc.lib.attributes.fluid.GroupedFluidInv;
|
||||
import alexiil.mc.lib.attributes.fluid.filter.ExactFluidFilter;
|
||||
import alexiil.mc.lib.attributes.fluid.filter.FluidFilter;
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
|
||||
@@ -31,9 +31,9 @@ import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.CraftingRecipe;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
@@ -70,7 +70,7 @@ public class CraftingPatternDetails implements ICraftingPatternDetails, Comparab
|
||||
|
||||
final List<IAEItemStack> ingredients = templateItem.getIngredients(itemStack);
|
||||
final List<IAEItemStack> products = templateItem.getProducts(itemStack);
|
||||
final ResourceLocation recipeId = templateItem.getCraftingRecipeId(itemStack);
|
||||
final Identifier recipeId = templateItem.getCraftingRecipeId(itemStack);
|
||||
|
||||
this.pattern = is.copy();
|
||||
this.isCraftable = recipeId != null;
|
||||
@@ -94,13 +94,13 @@ public class CraftingPatternDetails implements ICraftingPatternDetails, Comparab
|
||||
}
|
||||
|
||||
if (this.isCraftable) {
|
||||
IRecipe<?> recipe = w.getRecipeManager().getRecipes(IRecipeType.CRAFTING).get(recipeId);
|
||||
Recipe<?> recipe = w.getRecipeManager().getAllOfType(RecipeType.CRAFTING).get(recipeId);
|
||||
|
||||
if (recipe == null || recipe.getType() != IRecipeType.CRAFTING) {
|
||||
if (recipe == null || recipe.getType() != RecipeType.CRAFTING) {
|
||||
throw new IllegalStateException("recipe id is not a crafting recipe");
|
||||
}
|
||||
|
||||
this.standardRecipe = (ICraftingRecipe) recipe;
|
||||
this.standardRecipe = (CraftingRecipe) recipe;
|
||||
this.correctOutput = this.standardRecipe.craft(this.crafting);
|
||||
|
||||
out.add(Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
|
||||
@@ -87,7 +87,6 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.me.GridAccessException;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package appeng.hooks;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.parts.CableRenderMode;
|
||||
import appeng.client.AppEngClient;
|
||||
import appeng.util.Platform;
|
||||
@@ -31,7 +31,7 @@ public class ClientTickHandler extends TickHandler {
|
||||
|
||||
private void onBeforeClientTick(MinecraftClient client) {
|
||||
this.tickColors(this.cliPlayerColors);
|
||||
final CableRenderMode currentMode = AEApi.instance().partHelper().getCableRenderMode();
|
||||
final CableRenderMode currentMode = Api.instance().partHelper().getCableRenderMode();
|
||||
if (currentMode != this.crm) {
|
||||
this.crm = currentMode;
|
||||
AppEngClient.instance().triggerUpdates();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.implementations.items.IStorageComponent;
|
||||
@@ -62,7 +62,7 @@ public class CondenserOutputDisplay implements RecipeDisplay {
|
||||
}
|
||||
|
||||
private List<EntryStack> getViableStorageComponents(CondenserOutput condenserOutput) {
|
||||
IMaterials materials = AEApi.instance().definitions().materials();
|
||||
IMaterials materials = Api.instance().definitions().materials();
|
||||
List<EntryStack> viableComponents = new ArrayList<>();
|
||||
this.addViableComponent(condenserOutput, viableComponents, materials.cell1kPart().stack(1));
|
||||
this.addViableComponent(condenserOutput, viableComponents, materials.cell4kPart().stack(1));
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
@@ -92,14 +92,14 @@ public class ReiPlugin implements REIPluginV0 {
|
||||
|
||||
@Override
|
||||
public void postRegister() {
|
||||
IDefinitions definitions = AEApi.instance().definitions();
|
||||
IDefinitions definitions = Api.instance().definitions();
|
||||
registerDescriptions(definitions);
|
||||
|
||||
ReiFacade.setInstance(new ReiRuntimeAdapter());
|
||||
}
|
||||
|
||||
private void registerWorkingStations(RecipeHelper registration) {
|
||||
IDefinitions definitions = AEApi.instance().definitions();
|
||||
IDefinitions definitions = Api.instance().definitions();
|
||||
|
||||
ItemStack grindstone = definitions.blocks().grindstone().stack(1);
|
||||
registration.registerWorkingStations(GrinderRecipeCategory.UID, EntryStack.create(grindstone));
|
||||
|
||||
@@ -23,30 +23,26 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import appeng.core.Api;
|
||||
import appeng.hooks.AEToolItem;
|
||||
import net.fabricmc.fabric.api.util.NbtType;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
@@ -56,7 +52,7 @@ import appeng.helpers.InvalidPatternHelper;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class EncodedPatternItem extends AEBaseItem, AEToolItem {
|
||||
public class EncodedPatternItem extends AEBaseItem implements AEToolItem {
|
||||
|
||||
public static final String NBT_INGREDIENTS = "in";
|
||||
public static final String NBT_PRODUCTS = "out";
|
||||
@@ -212,32 +208,32 @@ public class EncodedPatternItem extends AEBaseItem, AEToolItem {
|
||||
|
||||
public boolean isEncodedPattern(ItemStack itemStack) {
|
||||
return itemStack != null && !itemStack.isEmpty() && itemStack.getItem() == this && itemStack.getTag() != null
|
||||
&& itemStack.getTag().contains(NBT_INGREDIENTS, Constants.NBT.TAG_LIST)
|
||||
&& itemStack.getTag().contains(NBT_PRODUCTS, Constants.NBT.TAG_LIST);
|
||||
&& itemStack.getTag().contains(NBT_INGREDIENTS, NbtType.LIST)
|
||||
&& itemStack.getTag().contains(NBT_PRODUCTS, NbtType.LIST);
|
||||
}
|
||||
|
||||
public ResourceLocation getCraftingRecipeId(ItemStack itemStack) {
|
||||
public Identifier getCraftingRecipeId(ItemStack itemStack) {
|
||||
Preconditions.checkArgument(itemStack.getItem() == this, "Given item stack %s is not an encoded pattern.",
|
||||
itemStack);
|
||||
final CompoundNBT tag = itemStack.getTag();
|
||||
final CompoundTag tag = itemStack.getTag();
|
||||
Preconditions.checkArgument(tag != null, "itemStack missing a NBT tag");
|
||||
|
||||
return new ResourceLocation(tag.getString(NBT_RECIPE_ID));
|
||||
return new Identifier(tag.getString(NBT_RECIPE_ID));
|
||||
}
|
||||
|
||||
public List<IAEItemStack> getIngredients(ItemStack itemStack) {
|
||||
Preconditions.checkArgument(itemStack.getItem() == this, "Given item stack %s is not an encoded pattern.",
|
||||
itemStack);
|
||||
final CompoundNBT tag = itemStack.getTag();
|
||||
final CompoundTag tag = itemStack.getTag();
|
||||
Preconditions.checkArgument(tag != null, "itemStack missing a NBT tag");
|
||||
|
||||
final ListNBT inTag = tag.getList(NBT_INGREDIENTS, 10);
|
||||
final ListTag inTag = tag.getList(NBT_INGREDIENTS, 10);
|
||||
Preconditions.checkArgument(inTag.size() < 10, "Cannot use more than 9 ingredients");
|
||||
|
||||
final List<IAEItemStack> in = new ArrayList<>(inTag.size());
|
||||
for (int x = 0; x < inTag.size(); x++) {
|
||||
CompoundNBT ingredient = inTag.getCompound(x);
|
||||
final ItemStack gs = ItemStack.read(ingredient);
|
||||
CompoundTag ingredient = inTag.getCompound(x);
|
||||
final ItemStack gs = ItemStack.fromTag(ingredient);
|
||||
|
||||
Preconditions.checkArgument(!(!ingredient.isEmpty() && gs.isEmpty()), "invalid itemStack in slot", x);
|
||||
|
||||
@@ -250,16 +246,16 @@ public class EncodedPatternItem extends AEBaseItem, AEToolItem {
|
||||
public List<IAEItemStack> getProducts(ItemStack itemStack) {
|
||||
Preconditions.checkArgument(itemStack.getItem() == this, "Given item stack %s is not an encoded pattern.",
|
||||
itemStack);
|
||||
final CompoundNBT tag = itemStack.getTag();
|
||||
final CompoundTag tag = itemStack.getTag();
|
||||
Preconditions.checkArgument(tag != null, "itemStack missing a NBT tag");
|
||||
|
||||
final ListNBT outTag = tag.getList(NBT_PRODUCTS, 10);
|
||||
final ListTag outTag = tag.getList(NBT_PRODUCTS, 10);
|
||||
Preconditions.checkArgument(outTag.size() < 4, "Cannot use more than 3 ingredients");
|
||||
|
||||
final List<IAEItemStack> out = new ArrayList<>(outTag.size());
|
||||
for (int x = 0; x < outTag.size(); x++) {
|
||||
CompoundNBT ingredient = outTag.getCompound(x);
|
||||
final ItemStack gs = ItemStack.read(ingredient);
|
||||
CompoundTag ingredient = outTag.getCompound(x);
|
||||
final ItemStack gs = ItemStack.fromTag(ingredient);
|
||||
|
||||
Preconditions.checkArgument(!(!ingredient.isEmpty() && gs.isEmpty()), "invalid itemStack in slot", x);
|
||||
|
||||
@@ -271,7 +267,7 @@ public class EncodedPatternItem extends AEBaseItem, AEToolItem {
|
||||
}
|
||||
|
||||
public boolean allowsSubstitution(ItemStack itemStack) {
|
||||
final CompoundNBT tag = itemStack.getTag();
|
||||
final CompoundTag tag = itemStack.getTag();
|
||||
|
||||
Preconditions.checkArgument(tag != null, "itemStack missing a NBT tag");
|
||||
|
||||
@@ -282,8 +278,8 @@ public class EncodedPatternItem extends AEBaseItem, AEToolItem {
|
||||
* Use the public API instead {@link appeng.core.api.ApiCrafting}
|
||||
*/
|
||||
public static void encodeCraftingPattern(ItemStack stack, ItemStack[] in, ItemStack[] out,
|
||||
ResourceLocation recipeId, boolean allowSubstitutes) {
|
||||
CompoundNBT encodedValue = encodeInputsAndOutputs(in, out);
|
||||
Identifier recipeId, boolean allowSubstitutes) {
|
||||
CompoundTag encodedValue = encodeInputsAndOutputs(in, out);
|
||||
encodedValue.putString(EncodedPatternItem.NBT_RECIPE_ID, recipeId.toString());
|
||||
encodedValue.putBoolean(EncodedPatternItem.NBT_SUBSITUTE, allowSubstitutes);
|
||||
stack.setTag(encodedValue);
|
||||
@@ -296,11 +292,11 @@ public class EncodedPatternItem extends AEBaseItem, AEToolItem {
|
||||
stack.setTag(encodeInputsAndOutputs(in, out));
|
||||
}
|
||||
|
||||
private static CompoundNBT encodeInputsAndOutputs(ItemStack[] in, ItemStack[] out) {
|
||||
final CompoundNBT encodedValue = new CompoundNBT();
|
||||
private static CompoundTag encodeInputsAndOutputs(ItemStack[] in, ItemStack[] out) {
|
||||
final CompoundTag encodedValue = new CompoundTag();
|
||||
|
||||
final ListNBT tagIn = new ListNBT();
|
||||
final ListNBT tagOut = new ListNBT();
|
||||
final ListTag tagIn = new ListTag();
|
||||
final ListTag tagOut = new ListTag();
|
||||
|
||||
for (final ItemStack i : in) {
|
||||
tagIn.add(createItemTag(i));
|
||||
@@ -315,11 +311,11 @@ public class EncodedPatternItem extends AEBaseItem, AEToolItem {
|
||||
return encodedValue;
|
||||
}
|
||||
|
||||
private static INBT createItemTag(final ItemStack i) {
|
||||
final CompoundNBT c = new CompoundNBT();
|
||||
private static Tag createItemTag(final ItemStack i) {
|
||||
final CompoundTag c = new CompoundTag();
|
||||
|
||||
if (!i.isEmpty()) {
|
||||
i.write(c);
|
||||
i.toTag(c);
|
||||
}
|
||||
|
||||
return c;
|
||||
|
||||
@@ -28,12 +28,7 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.RenderLayers;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
import net.minecraft.tag.Tag;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.implementations.items.IStorageCell;
|
||||
|
||||
@@ -33,11 +33,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.recipe.SmeltingRecipe;
|
||||
@@ -45,11 +41,8 @@ import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
@@ -35,7 +35,7 @@ import net.minecraft.util.Hand;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
|
||||
@@ -25,7 +25,7 @@ import alexiil.mc.lib.attributes.fluid.amount.FluidAmount;
|
||||
import alexiil.mc.lib.attributes.fluid.filter.ExactFluidFilter;
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidKey;
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.StorageFilter;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package appeng.mixins;
|
||||
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.BakedModelManager;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(BakedModelManager.class)
|
||||
public interface BakedModelManagerAccessor {
|
||||
|
||||
@Accessor
|
||||
Map<Identifier, BakedModel> getModels();
|
||||
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package appeng.parts;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.api.parts.*;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package appeng.spatial;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.movable.IMovableHandler;
|
||||
import appeng.api.movable.IMovableRegistry;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package appeng.spatial;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package appeng.spatial;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
@@ -246,7 +246,7 @@ public class CraftingBlockEntity extends AENetworkBlockEntity implements IAEMult
|
||||
// Since breaking the cluster will most likely also update the TE's state,
|
||||
// it's essential that we're not working with outdated block-state information,
|
||||
// since this particular TE's block might already have been removed (state=air)
|
||||
updateContainingBlockInfo();
|
||||
resetBlock();
|
||||
|
||||
if (this.cluster != null) {
|
||||
this.cluster.cancel();
|
||||
|
||||
@@ -4,7 +4,7 @@ package appeng.tile.inventory;
|
||||
import alexiil.mc.lib.attributes.Simulation;
|
||||
import alexiil.mc.lib.attributes.item.filter.ItemFilter;
|
||||
import alexiil.mc.lib.attributes.item.impl.DelegatingFixedItemInv;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.storage.cells.ICellInventory;
|
||||
import appeng.api.storage.cells.ICellInventoryHandler;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
@@ -12,7 +12,7 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public class AppEngCellInventory extends DelegatingFixedItemInv {
|
||||
private static final ItemFilter CELL_FILTER = stack -> !stack.isEmpty()
|
||||
&& AEApi.instance().registries().cell().isCellHandled(stack);
|
||||
&& Api.instance().registries().cell().isCellHandled(stack);
|
||||
|
||||
private final ICellInventoryHandler<?>[] handlerForSlot;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package appeng.tile.misc;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.definitions.IComparableDefinition;
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
import appeng.core.Api;
|
||||
|
||||
@@ -286,7 +286,7 @@ public class QuantumBridgeBlockEntity extends AENetworkInvBlockEntity implements
|
||||
// Since breaking the cluster will most likely also update the TE's state,
|
||||
// it's essential that we're not working with outdated block-state information,
|
||||
// since this particular TE's block might already have been removed (state=air)
|
||||
updateContainingBlockInfo();
|
||||
resetBlock();
|
||||
|
||||
if (this.cluster != null) {
|
||||
this.cluster.destroy();
|
||||
|
||||
@@ -27,7 +27,7 @@ import alexiil.mc.lib.attributes.fluid.filter.ConstantFluidFilter;
|
||||
import alexiil.mc.lib.attributes.fluid.filter.FluidFilter;
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.implementations.tiles.IColorableTile;
|
||||
import appeng.api.implementations.tiles.IMEChest;
|
||||
@@ -74,6 +74,7 @@ import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
@@ -258,7 +259,7 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
return null;
|
||||
}
|
||||
// Client-side we'll need to actually use the synced state
|
||||
if (world == null || world.isRemote) {
|
||||
if (world == null || world.isClient) {
|
||||
return cellItem;
|
||||
}
|
||||
ItemStack cell = getCell();
|
||||
@@ -357,7 +358,7 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
// when it changes from
|
||||
// empty->non-empty, so when the cell is changed, it should re-send the state
|
||||
// because of that
|
||||
data.writeRegistryIdUnsafe(ForgeRegistries.ITEMS, getCell().getItem().getRegistryName());
|
||||
data.writeVarInt(Item.getRawId(getCell().getItem()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -369,7 +370,7 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
this.state = data.readByte();
|
||||
final AEColor oldPaintedColor = this.paintedColor;
|
||||
this.paintedColor = AEColor.values()[data.readByte()];
|
||||
this.cellItem = data.readRegistryIdUnsafe(ForgeRegistries.ITEMS);
|
||||
this.cellItem = Item.byRawId(data.readVarInt());
|
||||
|
||||
this.lastStateChange = this.world.getTime();
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import appeng.client.render.model.DriveModelData;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
@@ -37,7 +38,6 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import appeng.api.networking.GridFlags;
|
||||
@@ -59,7 +59,6 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.block.storage.DriveSlotsState;
|
||||
import appeng.client.render.model.DriveModelData;
|
||||
import appeng.container.implementations.DriveContainer;
|
||||
import appeng.core.Api;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
@@ -70,9 +69,7 @@ import appeng.tile.grid.AENetworkInvBlockEntity;
|
||||
import appeng.tile.inventory.AppEngCellInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
public class DriveBlockEntity extends AENetworkInvBlockEntity implements IChestOrDrive, IPriorityHost {
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package appeng.util;
|
||||
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.Api;
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
|
||||
Reference in New Issue
Block a user