Fabric port in progress
This commit is contained in:
@@ -15,7 +15,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.render.model.IBakedModel;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.ItemOverrideList;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
@@ -28,7 +28,7 @@ import net.minecraftforge.client.model.data.IModelData;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.qnb.QuantumBridgeTileEntity;
|
||||
import appeng.tile.qnb.QuantumBridgeBlockEntity;
|
||||
|
||||
class QnbFormedBakedModel implements IDynamicBakedModel {
|
||||
|
||||
@@ -54,7 +54,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
|
||||
private static final float CENTER_POWERED_RENDER_MIN = -0.01f;
|
||||
private static final float CENTER_POWERED_RENDER_MAX = 16.01f;
|
||||
|
||||
private final IBakedModel baseModel;
|
||||
private final BakedModel baseModel;
|
||||
|
||||
private final Block linkBlock;
|
||||
|
||||
@@ -65,7 +65,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
|
||||
private final TextureAtlasSprite lightTexture;
|
||||
private final TextureAtlasSprite lightCornerTexture;
|
||||
|
||||
public QnbFormedBakedModel(IBakedModel baseModel, Function<Material, TextureAtlasSprite> bakedTextureGetter) {
|
||||
public QnbFormedBakedModel(BakedModel baseModel, Function<Material, TextureAtlasSprite> bakedTextureGetter) {
|
||||
this.baseModel = baseModel;
|
||||
this.linkTexture = bakedTextureGetter.apply(TEXTURE_LINK);
|
||||
this.ringTexture = bakedTextureGetter.apply(TEXTURE_RING);
|
||||
@@ -79,7 +79,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand,
|
||||
IModelData modelData) {
|
||||
QnbFormedState formedState = modelData.getData(QuantumBridgeTileEntity.FORMED_STATE);
|
||||
QnbFormedState formedState = modelData.getData(QuantumBridgeBlockEntity.FORMED_STATE);
|
||||
|
||||
if (formedState == null) {
|
||||
return this.baseModel.getQuads(state, side, rand);
|
||||
@@ -121,9 +121,9 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
|
||||
// Offset the face by a slight amount so that it is drawn over the already drawn
|
||||
// ring texture
|
||||
// (avoids z-fighting)
|
||||
float xOffset = Math.abs(facing.getXOffset() * 0.01f);
|
||||
float yOffset = Math.abs(facing.getYOffset() * 0.01f);
|
||||
float zOffset = Math.abs(facing.getZOffset() * 0.01f);
|
||||
float xOffset = Math.abs(facing.getOffsetX() * 0.01f);
|
||||
float yOffset = Math.abs(facing.getOffsetY() * 0.01f);
|
||||
float zOffset = Math.abs(facing.getOffsetZ() * 0.01f);
|
||||
|
||||
builder.setDrawFaces(EnumSet.of(facing));
|
||||
builder.addCube(DEFAULT_RENDER_MIN - xOffset, DEFAULT_RENDER_MIN - yOffset,
|
||||
@@ -147,9 +147,9 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
|
||||
// Offset the face by a slight amount so that it is drawn over the already drawn
|
||||
// ring texture
|
||||
// (avoids z-fighting)
|
||||
float xOffset = Math.abs(facing.getXOffset() * 0.01f);
|
||||
float yOffset = Math.abs(facing.getYOffset() * 0.01f);
|
||||
float zOffset = Math.abs(facing.getZOffset() * 0.01f);
|
||||
float xOffset = Math.abs(facing.getOffsetX() * 0.01f);
|
||||
float yOffset = Math.abs(facing.getOffsetY() * 0.01f);
|
||||
float zOffset = Math.abs(facing.getOffsetZ() * 0.01f);
|
||||
|
||||
builder.setDrawFaces(EnumSet.of(facing));
|
||||
builder.addCube(-xOffset, -yOffset, -zOffset, 16 + xOffset, 16 + yOffset, 16 + zOffset);
|
||||
|
||||
@@ -7,12 +7,12 @@ import java.util.function.Function;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
||||
import net.minecraft.client.render.model.IBakedModel;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.IModelTransform;
|
||||
import net.minecraft.client.render.model.IUnbakedModel;
|
||||
import net.minecraft.client.render.model.ItemOverrideList;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.render.model.ModelBakery;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
@@ -25,10 +25,10 @@ public class QnbFormedModel implements IModelGeometry<QnbFormedModel> {
|
||||
private static final Identifier MODEL_RING = new Identifier(AppEng.MOD_ID, "block/qnb/ring");
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
|
||||
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
|
||||
ItemOverrideList overrides, Identifier modelLocation) {
|
||||
IBakedModel ringModel = bakery.getBakedModel(MODEL_RING, modelTransform, spriteGetter);
|
||||
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
|
||||
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
|
||||
ItemOverrideList overrides, Identifier modelLocation) {
|
||||
BakedModel ringModel = bakery.getBakedModel(MODEL_RING, modelTransform, spriteGetter);
|
||||
return new QnbFormedBakedModel(ringModel, spriteGetter);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@ import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.tile.qnb.QuantumBridgeTileEntity;
|
||||
import appeng.tile.qnb.QuantumBridgeBlockEntity;
|
||||
|
||||
public abstract class QuantumBaseBlock extends AEBaseTileBlock<QuantumBridgeTileEntity> {
|
||||
public abstract class QuantumBaseBlock extends AEBaseTileBlock<QuantumBridgeBlockEntity> {
|
||||
|
||||
public static final BooleanProperty FORMED = BooleanProperty.create("formed");
|
||||
|
||||
@@ -62,31 +62,31 @@ public abstract class QuantumBaseBlock extends AEBaseTileBlock<QuantumBridgeTile
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, QuantumBridgeTileEntity te) {
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, QuantumBridgeBlockEntity te) {
|
||||
return currentState.with(FORMED, te.isFormed());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final QuantumBridgeTileEntity bridge = this.getTileEntity(world, pos);
|
||||
final QuantumBridgeBlockEntity bridge = this.getBlockEntity(world, pos);
|
||||
if (bridge != null) {
|
||||
bridge.neighborUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
public void onStateReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (newState.getBlock() == state.getBlock()) {
|
||||
return; // Just a block state change
|
||||
}
|
||||
|
||||
final QuantumBridgeTileEntity bridge = this.getTileEntity(w, pos);
|
||||
final QuantumBridgeBlockEntity bridge = this.getBlockEntity(w, pos);
|
||||
if (bridge != null) {
|
||||
bridge.breakCluster();
|
||||
}
|
||||
|
||||
super.onReplaced(state, w, pos, newState, isMoving);
|
||||
super.onStateReplaced(state, w, pos, newState, isMoving);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
package appeng.block.qnb;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
@@ -14,7 +14,7 @@ public class QuantumBridgeRendering extends BlockRenderingCustomizer {
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
rendering.renderType(RenderLayer.getCutout());
|
||||
// Disable auto rotation
|
||||
rendering.modelCustomizer((location, model) -> model);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
@@ -42,7 +42,7 @@ import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.QNBContainer;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.tile.qnb.QuantumBridgeTileEntity;
|
||||
import appeng.tile.qnb.QuantumBridgeBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class QuantumLinkChamberBlock extends QuantumBaseBlock {
|
||||
@@ -61,7 +61,7 @@ public class QuantumLinkChamberBlock extends QuantumBaseBlock {
|
||||
|
||||
@Override
|
||||
public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random rand) {
|
||||
final QuantumBridgeTileEntity bridge = this.getTileEntity(w, pos);
|
||||
final QuantumBridgeBlockEntity bridge = this.getBlockEntity(w, pos);
|
||||
if (bridge != null) {
|
||||
if (bridge.hasQES()) {
|
||||
if (AppEng.proxy.shouldAddParticles(rand)) {
|
||||
@@ -74,12 +74,12 @@ public class QuantumLinkChamberBlock extends QuantumBaseBlock {
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (p.isCrouching()) {
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
if (p.isInSneakingPose()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
final QuantumBridgeTileEntity tg = this.getTileEntity(w, pos);
|
||||
final QuantumBridgeBlockEntity tg = this.getBlockEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(QNBContainer.TYPE, p, ContainerLocator.forTileEntity(tg));
|
||||
|
||||
@@ -27,7 +27,7 @@ import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
|
||||
import appeng.tile.qnb.QuantumBridgeTileEntity;
|
||||
import appeng.tile.qnb.QuantumBridgeBlockEntity;
|
||||
|
||||
public class QuantumRingBlock extends QuantumBaseBlock {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class QuantumRingBlock extends QuantumBaseBlock {
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
|
||||
final QuantumBridgeTileEntity bridge = this.getTileEntity(w, pos);
|
||||
final QuantumBridgeBlockEntity bridge = this.getBlockEntity(w, pos);
|
||||
if (bridge != null && bridge.isCorner()) {
|
||||
return SHAPE_CORNER;
|
||||
} else if (bridge != null && bridge.isFormed()) {
|
||||
|
||||
Reference in New Issue
Block a user