More lens fixes.

This commit is contained in:
Flanks255 2022-06-24 14:23:43 -05:00
parent ec8cb4888c
commit 2538de7a4f
8 changed files with 53 additions and 75 deletions

View file

@ -20,6 +20,7 @@ import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
import de.ellpeck.actuallyadditions.api.recipe.*;
import de.ellpeck.actuallyadditions.mod.crafting.*;
import de.ellpeck.actuallyadditions.mod.items.lens.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.Item;
@ -99,14 +100,13 @@ public final class ActuallyAdditionsAPI {
//These are getting initialized in Actually Additions' PreInit phase
//DO NOT CHANGE/OVERRIDE THESE!!
public static LensConversion lensDefaultConversion;
public static Lens lensDetonation;
public static Lens lensDeath;
public static Lens lensEvenMoarDeath;
public static Lens lensColor;
public static Lens lensDisruption;
public static Lens lensDisenchanting;
public static Lens lensMining;
public static final LensConversion lensDefaultConversion = new LensConversion();
public static final Lens lensDetonation = new LensDetonation();
public static final Lens lensDeath = new LensDeath();
public static final Lens lensEvenMoarDeath = new LensKiller();
public static final Lens lensColor = new LensColor();
public static final Lens lensDisenchanting = new LensDisenchanting();
public static final Lens lensMining = new LensMining();
/**
* Adds an ore with a specific weight to the list of ores that the lens of the miner will generate inside of stone.

View file

@ -123,7 +123,7 @@ public class ActuallyAdditions {
ActuallyAdditionsAPI.methodHandler = new MethodHandler();
ActuallyAdditionsAPI.connectionHandler = new LaserRelayConnectionHandler();
Lenses.init();
//Lenses.init();
// CompatUtil.registerCraftingTweaks();
event.enqueueWork(() -> CraftingHelper.register(TargetNBTIngredient.Serializer.NAME, TargetNBTIngredient.SERIALIZER));

View file

@ -63,29 +63,29 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im
if (!world.isClientSide) {
TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor) world.getBlockEntity(pos);
if (reconstructor != null) {
if (StackUtil.isValid(heldItem)) {
if (!heldItem.isEmpty()) {
Item item = heldItem.getItem();
if (item instanceof ILensItem && !StackUtil.isValid(reconstructor.inv.getStackInSlot(0))) {
if (item instanceof ILensItem && reconstructor.inv.getStackInSlot(0).isEmpty()) {
ItemStack toPut = heldItem.copy();
toPut.setCount(1);
reconstructor.inv.setStackInSlot(0, toPut);
player.inventory.removeItem(player.inventory.selected, 1);
}
//Shush, don't tell anyone!
else if (CommonConfig.Other.ELEVEN.get() == 11 && item == Items.MUSIC_DISC_11) {
reconstructor.counter++;
reconstructor.setChanged();
if (!player.isCreative()) {
heldItem.shrink(1);
}
return ActionResultType.CONSUME;
}
} else {
ItemStack slot = reconstructor.inv.getStackInSlot(0);
if (StackUtil.isValid(slot)) {
if (!slot.isEmpty() && hand == Hand.MAIN_HAND) {
player.setItemInHand(hand, slot.copy());
reconstructor.inv.setStackInSlot(0, StackUtil.getEmpty());
reconstructor.inv.setStackInSlot(0, ItemStack.EMPTY);
return ActionResultType.CONSUME;
}
}
}
return ActionResultType.FAIL;
}
return ActionResultType.PASS;
return ActionResultType.CONSUME;
}
@Nullable

View file

@ -18,6 +18,7 @@ import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.ItemStack;
@ -25,6 +26,9 @@ import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3f;
import javax.annotation.Nonnull;
public class ReconstructorRenderer extends TileEntityRenderer<TileEntityAtomicReconstructor> {
@ -33,62 +37,36 @@ public class ReconstructorRenderer extends TileEntityRenderer<TileEntityAtomicRe
}
@Override
public void render(TileEntityAtomicReconstructor tile, float partialTicks, MatrixStack matrices, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay) {
public void render(TileEntityAtomicReconstructor tile, float partialTicks, @Nonnull MatrixStack matrices, @Nonnull IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay) {
ItemStack stack = tile.inv.getStackInSlot(0);
//default color 0x1b6dff
Direction direction = tile.getOrientation();
float rot = 360.0f - direction.getOpposite().toYRot(); //Sigh...
float pitch = 0;
if (direction == Direction.UP) {
pitch = 90;
} else if (direction == Direction.DOWN) {
pitch = -90;
}
if (tile.getProgress() > 0) {
Direction direction = tile.getOrientation();
float rot = 360.0f - direction.getOpposite().toYRot(); //Sigh...
float pitch = 0;
if (direction == Direction.UP) {
pitch = 90;
} else if (direction == Direction.DOWN) {
pitch = -90;
}
AssetUtil.renderLaser(matrices, buffer, 0, 0, 0, rot, pitch, 5, 0, 0x1b6dff, 0.8f * tile.getProgress(), 0.2f);
tile.decTTL();
}
if (!StackUtil.isValid(stack) || !(stack.getItem() instanceof ILensItem)) {
if (stack.isEmpty() || !(stack.getItem() instanceof ILensItem)) {
return;
}
matrices.pushPose();
matrices.translate(0.5F, 0.5F, 0.5F);
matrices.mulPose(new Quaternion(180F, 0.0F, 0.0F, 1.0F));
BlockState state = tile.getLevel().getBlockState(tile.getBlockPos());
int meta = 0; //state.getBlock().getMetaFromState(state); // TODO: [port][fix] this needs to be checking direction not meta
if (meta == 0) {
matrices.translate(0F, -0.5F, 0F);
matrices.mulPose(new Quaternion(90F, 1F, 0F, 0F));
}
if (meta == 1) {
matrices.translate(0F, -1.5F - 0.5F / 16F, 0F);
matrices.mulPose(new Quaternion(90F, 1F, 0F, 0F));
}
if (meta == 2) {
matrices.translate(0F, -1F, 0F);
matrices.translate(0F, 0F, -0.5F);
}
if (meta == 3) {
matrices.translate(0F, -1F, 0F);
matrices.translate(0F, 0F, 0.5F + 0.5F / 16F);
}
if (meta == 4) {
matrices.translate(0F, -1F, 0F);
matrices.translate(0.5F + 0.5F / 16F, 0F, 0F);
matrices.mulPose(new Quaternion(90F, 0F, 1F, 0F));
}
if (meta == 5) {
matrices.translate(0F, -1F, 0F);
matrices.translate(-0.5F, 0F, 0F);
matrices.mulPose(new Quaternion(90F, 0F, 1F, 0F));
}
matrices.mulPose(Vector3f.YP.rotationDegrees(rot));
matrices.mulPose(Vector3f.XP.rotationDegrees(pitch));
matrices.translate(0.0F, 0.0F, -0.5F);
matrices.scale(0.5F, 0.5F, 0.5F);
AssetUtil.renderItemInWorld(stack, combinedLight, combinedOverlay, matrices, buffer);
int lightColor = WorldRenderer.getLightColor(tile.getLevel(), tile.getPosition().relative(direction));
AssetUtil.renderItemInWorld(stack, lightColor, combinedOverlay, matrices, buffer);
matrices.popPose();
}

View file

@ -24,15 +24,17 @@ import net.minecraft.util.Util;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3f;
import javax.annotation.Nonnull;
public class RenderDisplayStand extends TileEntityRenderer<TileEntityDisplayStand> {
public RenderDisplayStand(TileEntityRendererDispatcher rendererDispatcherIn) {
super(rendererDispatcherIn);
}
@Override
public void render(TileEntityDisplayStand tile, float partialTicks, MatrixStack matrices, IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn) {
public void render(TileEntityDisplayStand tile, float partialTicks, @Nonnull MatrixStack matrices, @Nonnull IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn) {
ItemStack stack = tile.inv.getStackInSlot(0);
if (!StackUtil.isValid(stack)) {
if (stack.isEmpty()) {
return;
}

View file

@ -16,12 +16,12 @@ import de.ellpeck.actuallyadditions.api.lens.LensConversion;
public final class Lenses {
public static void init() {
ActuallyAdditionsAPI.lensDefaultConversion = new LensConversion();
ActuallyAdditionsAPI.lensDetonation = new LensDetonation();
ActuallyAdditionsAPI.lensDeath = new LensDeath();
ActuallyAdditionsAPI.lensEvenMoarDeath = new LensKiller();
ActuallyAdditionsAPI.lensColor = new LensColor();
ActuallyAdditionsAPI.lensDisenchanting = new LensDisenchanting();
ActuallyAdditionsAPI.lensMining = new LensMining();
// ActuallyAdditionsAPI.lensDefaultConversion = new LensConversion();
// ActuallyAdditionsAPI.lensDetonation = new LensDetonation();
// ActuallyAdditionsAPI.lensDeath = new LensDeath();
// ActuallyAdditionsAPI.lensEvenMoarDeath = new LensKiller();
// ActuallyAdditionsAPI.lensColor = new LensColor();
// ActuallyAdditionsAPI.lensDisenchanting = new LensDisenchanting();
// ActuallyAdditionsAPI.lensMining = new LensMining();
}
}

View file

@ -132,9 +132,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
if (item instanceof ILensItem) {
return ((ILensItem) item).getLens();
}
return this.counter >= 500
? ActuallyAdditionsAPI.lensDisruption
: ActuallyAdditionsAPI.lensDefaultConversion;
return ActuallyAdditionsAPI.lensDefaultConversion;
}
@Override

View file

@ -76,7 +76,7 @@ public final class AssetUtil {
@OnlyIn(Dist.CLIENT)
public static void renderItemInWorld(ItemStack stack, int combinedLight, int combinedOverlay, MatrixStack matrices, IRenderTypeBuffer buffer) {
if (StackUtil.isValid(stack)) {
if (!stack.isEmpty()) {
Minecraft.getInstance().getItemRenderer().renderStatic(
stack, ItemCameraTransforms.TransformType.FIXED, combinedLight, combinedOverlay, matrices, buffer
);