Merge remote-tracking branch 'origin/master' into fabric-1.16
This commit is contained in:
@@ -36,10 +36,10 @@ public interface IGridCacheRegistry {
|
|||||||
* Register a new grid cache for use during operation, must be called during the
|
* Register a new grid cache for use during operation, must be called during the
|
||||||
* loading phase.
|
* loading phase.
|
||||||
*
|
*
|
||||||
* @param iface grid cache class
|
* @param iface grid cache class
|
||||||
|
* @param factory Factory for creating a new instance for each constructed grid
|
||||||
*/
|
*/
|
||||||
void registerGridCache(@Nonnull Class<? extends IGridCache> iface,
|
<T extends IGridCache> void registerGridCache(@Nonnull Class<T> iface, @Nonnull IGridCacheFactory<T> factory);
|
||||||
@Nonnull Class<? extends IGridCache> implementation);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* requests a new INSTANCE of a grid cache for use, used internally
|
* requests a new INSTANCE of a grid cache for use, used internally
|
||||||
|
|||||||
@@ -353,7 +353,9 @@ public interface IPart extends ICustomCableConnection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This will be used by the core to add information about this part to a crash
|
* This will be used by the core to add information about this part to a crash
|
||||||
* report if it is attached to a host that caused a crash during tick processing.
|
* report if it is attached to a host that caused a crash during tick
|
||||||
|
* processing.
|
||||||
|
*
|
||||||
* @param section The crash report section the information will be added to.
|
* @param section The crash report section the information will be added to.
|
||||||
*/
|
*/
|
||||||
default void addEntityCrashInfo(CrashReportSection section) {
|
default void addEntityCrashInfo(CrashReportSection section) {
|
||||||
|
|||||||
@@ -18,54 +18,57 @@
|
|||||||
|
|
||||||
package appeng.core.features.registries;
|
package appeng.core.features.registries;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.util.ArrayList;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import appeng.api.networking.IGrid;
|
import appeng.api.networking.IGrid;
|
||||||
import appeng.api.networking.IGridCache;
|
import appeng.api.networking.IGridCache;
|
||||||
|
import appeng.api.networking.IGridCacheFactory;
|
||||||
import appeng.api.networking.IGridCacheRegistry;
|
import appeng.api.networking.IGridCacheRegistry;
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
|
|
||||||
public final class GridCacheRegistry implements IGridCacheRegistry {
|
public final class GridCacheRegistry implements IGridCacheRegistry {
|
||||||
private final Map<Class<? extends IGridCache>, Class<? extends IGridCache>> caches = new HashMap<>();
|
|
||||||
|
private final List<GridCacheRegistration<?>> registry = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerGridCache(final Class<? extends IGridCache> iface,
|
public synchronized <T extends IGridCache> void registerGridCache(@Nonnull Class<T> iface,
|
||||||
final Class<? extends IGridCache> implementation) {
|
@Nonnull IGridCacheFactory<T> factory) {
|
||||||
if (iface.isAssignableFrom(implementation)) {
|
|
||||||
this.caches.put(iface, implementation);
|
if (registry.stream().anyMatch(r -> r.cacheClass.equals(iface))) {
|
||||||
} else {
|
throw new IllegalArgumentException("Implementation for grid cache " + iface + " is already registered!");
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Invalid setup, grid cache must either be the same class, or an interface that the implementation implements. Gotten: "
|
|
||||||
+ iface + " and " + implementation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registry.add(new GridCacheRegistration<>(iface, factory));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashMap<Class<? extends IGridCache>, IGridCache> createCacheInstance(final IGrid g) {
|
public Map<Class<? extends IGridCache>, IGridCache> createCacheInstance(final IGrid g) {
|
||||||
final HashMap<Class<? extends IGridCache>, IGridCache> map = new HashMap<>();
|
final Map<Class<? extends IGridCache>, IGridCache> map = new HashMap<>(registry.size());
|
||||||
|
|
||||||
for (final Class<? extends IGridCache> iface : this.caches.keySet()) {
|
for (GridCacheRegistration<?> registration : registry) {
|
||||||
try {
|
map.put(registration.cacheClass, registration.factory.createCache(g));
|
||||||
final Constructor<? extends IGridCache> c = this.caches.get(iface).getConstructor(IGrid.class);
|
|
||||||
map.put(iface, c.newInstance(g));
|
|
||||||
} catch (final NoSuchMethodException e) {
|
|
||||||
AELog.error("Grid Caches must have a constructor with IGrid as the single param.");
|
|
||||||
throw new IllegalArgumentException(e);
|
|
||||||
} catch (final InvocationTargetException e) {
|
|
||||||
AELog.error("Grid Caches must have a constructor with IGrid as the single param.");
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
} catch (final InstantiationException e) {
|
|
||||||
AELog.error("Grid Caches must have a constructor with IGrid as the single param.");
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
} catch (final IllegalAccessException e) {
|
|
||||||
AELog.error("Grid Caches must have a constructor with IGrid as the single param.");
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class GridCacheRegistration<T extends IGridCache> {
|
||||||
|
|
||||||
|
private final Class<T> cacheClass;
|
||||||
|
|
||||||
|
private final IGridCacheFactory<T> factory;
|
||||||
|
|
||||||
|
public GridCacheRegistration(Class<T> cacheClass, IGridCacheFactory<T> factory) {
|
||||||
|
this.cacheClass = cacheClass;
|
||||||
|
this.factory = factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,7 +259,10 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
|
|||||||
@Override
|
@Override
|
||||||
public void writeToPacket(final PacketByteBuf buffer) {
|
public void writeToPacket(final PacketByteBuf buffer) {
|
||||||
buffer.writeBoolean(this.isCraftable());
|
buffer.writeBoolean(this.isCraftable());
|
||||||
buffer.writeCompoundTag(this.getFluidStack().toTag());
|
// Cannot use writeFluidStack here because for FluidStacks with amount==0, it
|
||||||
|
// will not write the fluid
|
||||||
|
buffer.writeRegistryIdUnsafe(ForgeRegistries.FLUIDS, fluid);
|
||||||
|
buffer.writeCompoundTag(getFluidStack().getTag());
|
||||||
buffer.writeVarLong(this.getStackSize());
|
buffer.writeVarLong(this.getStackSize());
|
||||||
buffer.writeVarLong(this.getCountRequestable());
|
buffer.writeVarLong(this.getCountRequestable());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import appeng.util.ReadOnlyCollection;
|
|||||||
public class Grid implements IGrid {
|
public class Grid implements IGrid {
|
||||||
private final NetworkEventBus eventBus = new NetworkEventBus();
|
private final NetworkEventBus eventBus = new NetworkEventBus();
|
||||||
private final Map<Class<? extends IGridHost>, MachineSet> machines = new HashMap<>();
|
private final Map<Class<? extends IGridHost>, MachineSet> machines = new HashMap<>();
|
||||||
private final Map<Class<? extends IGridCache>, GridCacheWrapper> caches = new HashMap<>();
|
private final Map<Class<? extends IGridCache>, GridCacheWrapper> caches;
|
||||||
private GridNode pivot;
|
private GridNode pivot;
|
||||||
private int priority; // how import is this network?
|
private int priority; // how import is this network?
|
||||||
private GridStorage myStorage;
|
private GridStorage myStorage;
|
||||||
@@ -52,6 +52,7 @@ public class Grid implements IGrid {
|
|||||||
|
|
||||||
final Map<Class<? extends IGridCache>, IGridCache> myCaches = AEApi.instance().registries().gridCache()
|
final Map<Class<? extends IGridCache>, IGridCache> myCaches = AEApi.instance().registries().gridCache()
|
||||||
.createCacheInstance(this);
|
.createCacheInstance(this);
|
||||||
|
this.caches = new HashMap<>(myCaches.size());
|
||||||
for (final Entry<Class<? extends IGridCache>, IGridCache> c : myCaches.entrySet()) {
|
for (final Entry<Class<? extends IGridCache>, IGridCache> c : myCaches.entrySet()) {
|
||||||
final Class<? extends IGridCache> key = c.getKey();
|
final Class<? extends IGridCache> key = c.getKey();
|
||||||
final IGridCache value = c.getValue();
|
final IGridCache value = c.getValue();
|
||||||
|
|||||||
+3
-12
@@ -40,7 +40,6 @@ import appeng.me.cache.helpers.TickTracker;
|
|||||||
|
|
||||||
public class TickManagerCache implements ITickManager {
|
public class TickManagerCache implements ITickManager {
|
||||||
|
|
||||||
private final IGrid myGrid;
|
|
||||||
private final HashMap<IGridNode, TickTracker> alertable = new HashMap<>();
|
private final HashMap<IGridNode, TickTracker> alertable = new HashMap<>();
|
||||||
private final HashMap<IGridNode, TickTracker> sleeping = new HashMap<>();
|
private final HashMap<IGridNode, TickTracker> sleeping = new HashMap<>();
|
||||||
private final HashMap<IGridNode, TickTracker> awake = new HashMap<>();
|
private final HashMap<IGridNode, TickTracker> awake = new HashMap<>();
|
||||||
@@ -48,12 +47,7 @@ public class TickManagerCache implements ITickManager {
|
|||||||
|
|
||||||
private long currentTick = 0;
|
private long currentTick = 0;
|
||||||
|
|
||||||
public TickManagerCache(final IGrid g) {
|
public TickManagerCache(@SuppressWarnings("unused") final IGrid g) {
|
||||||
this.myGrid = g;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCurrentTick() {
|
|
||||||
return this.currentTick;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getAvgNanoTime(final IGridNode node) {
|
public long getAvgNanoTime(final IGridNode node) {
|
||||||
@@ -67,7 +61,7 @@ public class TickManagerCache implements ITickManager {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tt.getAvgNanos();
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -147,7 +141,7 @@ public class TickManagerCache implements ITickManager {
|
|||||||
|
|
||||||
Preconditions.checkNotNull(tr);
|
Preconditions.checkNotNull(tr);
|
||||||
|
|
||||||
final TickTracker tt = new TickTracker(tr, gridNode, (IGridTickable) machine, this.currentTick, this);
|
final TickTracker tt = new TickTracker(tr, gridNode, (IGridTickable) machine, this.currentTick);
|
||||||
|
|
||||||
if (tr.canBeAlerted) {
|
if (tr.canBeAlerted) {
|
||||||
this.alertable.put(gridNode, tt);
|
this.alertable.put(gridNode, tt);
|
||||||
@@ -185,9 +179,6 @@ public class TickManagerCache implements ITickManager {
|
|||||||
if (tt == null) {
|
if (tt == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// throw new RuntimeException(
|
|
||||||
// "Invalid alerted device, this node is not marked as alertable, or part of
|
|
||||||
// this grid." );
|
|
||||||
|
|
||||||
// set to awake, this is for sanity.
|
// set to awake, this is for sanity.
|
||||||
this.sleeping.remove(node);
|
this.sleeping.remove(node);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import net.minecraft.util.crash.CrashReportSection;
|
|||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
import appeng.api.networking.ticking.IGridTickable;
|
import appeng.api.networking.ticking.IGridTickable;
|
||||||
import appeng.api.networking.ticking.TickingRequest;
|
import appeng.api.networking.ticking.TickingRequest;
|
||||||
|
import appeng.api.parts.IPart;
|
||||||
import appeng.api.util.DimensionalCoord;
|
import appeng.api.util.DimensionalCoord;
|
||||||
import appeng.me.cache.TickManagerCache;
|
import appeng.me.cache.TickManagerCache;
|
||||||
|
|
||||||
@@ -35,13 +36,10 @@ public class TickTracker implements Comparable<TickTracker> {
|
|||||||
private final IGridTickable gt;
|
private final IGridTickable gt;
|
||||||
private final IGridNode node;
|
private final IGridNode node;
|
||||||
|
|
||||||
private final long LastFiveTicksTime = 0;
|
|
||||||
|
|
||||||
private long lastTick;
|
private long lastTick;
|
||||||
private int currentRate;
|
private int currentRate;
|
||||||
|
|
||||||
public TickTracker(final TickingRequest req, final IGridNode node, final IGridTickable gt, final long currentTick,
|
public TickTracker(final TickingRequest req, final IGridNode node, final IGridTickable gt, final long currentTick) {
|
||||||
final TickManagerCache tickManagerCache) {
|
|
||||||
this.request = req;
|
this.request = req;
|
||||||
this.gt = gt;
|
this.gt = gt;
|
||||||
this.node = node;
|
this.node = node;
|
||||||
@@ -49,10 +47,6 @@ public class TickTracker implements Comparable<TickTracker> {
|
|||||||
this.setLastTick(currentTick);
|
this.setLastTick(currentTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getAvgNanos() {
|
|
||||||
return (this.LastFiveTicksTime / 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(@Nonnull final TickTracker t) {
|
public int compareTo(@Nonnull final TickTracker t) {
|
||||||
int next = Long.compare(this.getNextTick(), t.getNextTick());
|
int next = Long.compare(this.getNextTick(), t.getNextTick());
|
||||||
|
|||||||
+3
-15
@@ -1,18 +1,6 @@
|
|||||||
{
|
{
|
||||||
|
"parent": "appliedenergistics2:block/drive/drive_cell",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "appliedenergistics2:block/drive/fluid_cell"
|
"cell": "appliedenergistics2:block/drive/fluid_cell"
|
||||||
},
|
}
|
||||||
"elements": [
|
|
||||||
{
|
|
||||||
"name": "Cell Backdrop",
|
|
||||||
"from": [9, 13, 1],
|
|
||||||
"to": [15, 15, 3],
|
|
||||||
"rotation": { "angle": 0, "axis": "y", "origin": [9, 8, 8] },
|
|
||||||
"faces": {
|
|
||||||
"north": { "uv": [0, 2, 6, 4], "texture": "#front" },
|
|
||||||
"up": { "uv": [0, 0, 6, 2], "texture": "#front" },
|
|
||||||
"down": { "uv": [0, 4, 6, 6], "texture": "#front" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-15
@@ -1,18 +1,6 @@
|
|||||||
{
|
{
|
||||||
|
"parent": "appliedenergistics2:block/drive/drive_cell",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "appliedenergistics2:block/drive/item_cell"
|
"cell": "appliedenergistics2:block/drive/item_cell"
|
||||||
},
|
}
|
||||||
"elements": [
|
|
||||||
{
|
|
||||||
"name": "Cell Backdrop",
|
|
||||||
"from": [9, 13, 1],
|
|
||||||
"to": [15, 15, 3],
|
|
||||||
"rotation": { "angle": 0, "axis": "y", "origin": [9, 8, 8] },
|
|
||||||
"faces": {
|
|
||||||
"north": { "uv": [0, 2, 6, 4], "texture": "#front" },
|
|
||||||
"up": { "uv": [0, 0, 6, 2], "texture": "#front" },
|
|
||||||
"down": { "uv": [0, 4, 6, 6], "texture": "#front" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013 AlgorithmX2
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package appeng.api.networking;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A factory for grid cache implementations.
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface IGridCacheFactory<T extends IGridCache> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a grid cache for the given grid.
|
||||||
|
*
|
||||||
|
* @param grid The grid for which the cache should be created.
|
||||||
|
* @return A new grid cache instance.
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
T createCache(IGrid grid);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -83,7 +83,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusBlockEntity> implemen
|
|||||||
public CableBusBlock() {
|
public CableBusBlock() {
|
||||||
super(defaultProps(AEGlassMaterial.INSTANCE)
|
super(defaultProps(AEGlassMaterial.INSTANCE)
|
||||||
.nonOpaque()
|
.nonOpaque()
|
||||||
.dropsNothing());
|
.dropsNothing().variableOpacity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class DriveBakedModel extends DelegateBakedModel {
|
|||||||
|
|
||||||
DriveSlotsState slotsState = driveModelData.getSlotsState();
|
DriveSlotsState slotsState = driveModelData.getSlotsState();
|
||||||
|
|
||||||
if (side == null && slotsState != null) {
|
if (slotsState != null) {
|
||||||
for (int row = 0; row < 5; row++) {
|
for (int row = 0; row < 5; row++) {
|
||||||
for (int col = 0; col < 2; col++) {
|
for (int col = 0; col < 2; col++) {
|
||||||
Matrix4f transform = new Matrix4f();
|
Matrix4f transform = new Matrix4f();
|
||||||
@@ -80,7 +80,7 @@ public class DriveBakedModel extends DelegateBakedModel {
|
|||||||
// Add the drive chassis
|
// Add the drive chassis
|
||||||
Item cell = slotsState.getCell(slot);
|
Item cell = slotsState.getCell(slot);
|
||||||
BakedModel cellChassisModel = getCellChassisModel(cell);
|
BakedModel cellChassisModel = getCellChassisModel(cell);
|
||||||
addModel(state, rand, extraData, result, cellChassisModel, transform);
|
addModel(state, rand, extraData, result, side, cellChassisModel, transform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,9 +112,9 @@ public class DriveBakedModel extends DelegateBakedModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void addModel(@Nullable BlockState state, @Nonnull Random rand, @Nonnull IModelData extraData,
|
private static void addModel(@Nullable BlockState state, @Nonnull Random rand, @Nonnull IModelData extraData,
|
||||||
List<BakedQuad> result, BakedModel bakedCell, Matrix4f transform) {
|
List<BakedQuad> result, Direction side, IBakedModel bakedCell, Matrix4f transform) {
|
||||||
MatrixVertexTransformer transformer = new MatrixVertexTransformer(transform);
|
MatrixVertexTransformer transformer = new MatrixVertexTransformer(transform);
|
||||||
for (BakedQuad bakedQuad : bakedCell.getQuads(state, null, rand, extraData)) {
|
for (BakedQuad bakedQuad : bakedCell.getQuads(state, side, rand, extraData)) {
|
||||||
BakedQuadBuilder builder = new BakedQuadBuilder();
|
BakedQuadBuilder builder = new BakedQuadBuilder();
|
||||||
transformer.setParent(builder);
|
transformer.setParent(builder);
|
||||||
transformer.setVertexFormat(builder.getVertexFormat());
|
transformer.setVertexFormat(builder.getVertexFormat());
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import net.minecraft.client.render.VertexConsumer;
|
|||||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||||
|
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
import net.minecraft.client.render.VertexConsumerProvider;
|
||||||
import net.minecraft.client.renderer.RenderState;
|
import net.minecraft.client.renderer.RenderState;
|
||||||
@@ -14,7 +17,6 @@ import net.minecraft.client.util.math.Vector3f;
|
|||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
|
||||||
|
|
||||||
import appeng.block.storage.DriveSlotState;
|
import appeng.block.storage.DriveSlotState;
|
||||||
import appeng.client.render.FacingToRotation;
|
import appeng.client.render.FacingToRotation;
|
||||||
@@ -26,6 +28,14 @@ import appeng.tile.storage.DriveBlockEntity;
|
|||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEntity> {
|
public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEntity> {
|
||||||
|
|
||||||
|
private static final RenderState.TransparencyState TRANSLUCENT_TRANSPARENCY = new RenderState.TransparencyState(
|
||||||
|
"translucent_transparency", () -> {
|
||||||
|
RenderSystem.enableBlend();
|
||||||
|
RenderSystem.defaultBlendFunc();
|
||||||
|
}, () -> {
|
||||||
|
RenderSystem.disableBlend();
|
||||||
|
});
|
||||||
|
|
||||||
private static final EnumMap<DriveSlotState, Vector3f> STATE_COLORS;
|
private static final EnumMap<DriveSlotState, Vector3f> STATE_COLORS;
|
||||||
|
|
||||||
// Color used for the cell indicator for blinking during recent activity
|
// Color used for the cell indicator for blinking during recent activity
|
||||||
@@ -80,11 +90,9 @@ public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEn
|
|||||||
FacingToRotation.get(drive.getForward(), drive.getUp()).push(ms);
|
FacingToRotation.get(drive.getForward(), drive.getUp()).push(ms);
|
||||||
ms.translate(-0.5, -0.5, -0.5);
|
ms.translate(-0.5, -0.5, -0.5);
|
||||||
|
|
||||||
RenderState.TransparencyState TRANSLUCENT_TRANSPARENCY = ObfuscationReflectionHelper
|
RenderType rt = RenderType.makeType("ae_drive_leds", DefaultVertexFormats.POSITION_COLOR, 7, 32565, false, true,
|
||||||
.getPrivateValue(RenderState.class, null, "field_228515_g_");
|
RenderType.State.getBuilder().transparency(TRANSLUCENT_TRANSPARENCY).build(false));
|
||||||
RenderLayer rt = RenderLayer.makeType("ae_drive_leds", DefaultVertexFormats.POSITION_COLOR, 7, 32565, false, true,
|
IVertexBuilder buffer = buffers.getBuffer(STATE);
|
||||||
RenderLayer.State.getBuilder().transparency(TRANSLUCENT_TRANSPARENCY).build(false));
|
|
||||||
VertexConsumer buffer = buffers.getBuffer(STATE);
|
|
||||||
|
|
||||||
for (int row = 0; row < 5; row++) {
|
for (int row = 0; row < 5; row++) {
|
||||||
for (int col = 0; col < 2; col++) {
|
for (int col = 0; col < 2; col++) {
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"textures": {
|
||||||
|
"cell": "appliedenergistics2:block/drive/item_cell"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"name": "Cell Backdrop",
|
||||||
|
"from": [9, 13, 1],
|
||||||
|
"to": [15, 15, 3],
|
||||||
|
"rotation": { "angle": 0, "axis": "y", "origin": [9, 8, 8] },
|
||||||
|
"faces": {
|
||||||
|
"north": {
|
||||||
|
"uv": [0, 2, 6, 4],
|
||||||
|
"texture": "#cell",
|
||||||
|
"cullface": "north"
|
||||||
|
},
|
||||||
|
"up": { "uv": [0, 0, 6, 2], "texture": "#cell", "cullface": "north" },
|
||||||
|
"down": { "uv": [0, 4, 6, 6], "texture": "#cell", "cullface": "north" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user