mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
More lens fixes.
This commit is contained in:
parent
ec8cb4888c
commit
2538de7a4f
8 changed files with 53 additions and 75 deletions
|
@ -20,6 +20,7 @@ import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
|
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.*;
|
import de.ellpeck.actuallyadditions.api.recipe.*;
|
||||||
import de.ellpeck.actuallyadditions.mod.crafting.*;
|
import de.ellpeck.actuallyadditions.mod.crafting.*;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.items.lens.*;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
@ -99,14 +100,13 @@ public final class ActuallyAdditionsAPI {
|
||||||
|
|
||||||
//These are getting initialized in Actually Additions' PreInit phase
|
//These are getting initialized in Actually Additions' PreInit phase
|
||||||
//DO NOT CHANGE/OVERRIDE THESE!!
|
//DO NOT CHANGE/OVERRIDE THESE!!
|
||||||
public static LensConversion lensDefaultConversion;
|
public static final LensConversion lensDefaultConversion = new LensConversion();
|
||||||
public static Lens lensDetonation;
|
public static final Lens lensDetonation = new LensDetonation();
|
||||||
public static Lens lensDeath;
|
public static final Lens lensDeath = new LensDeath();
|
||||||
public static Lens lensEvenMoarDeath;
|
public static final Lens lensEvenMoarDeath = new LensKiller();
|
||||||
public static Lens lensColor;
|
public static final Lens lensColor = new LensColor();
|
||||||
public static Lens lensDisruption;
|
public static final Lens lensDisenchanting = new LensDisenchanting();
|
||||||
public static Lens lensDisenchanting;
|
public static final Lens lensMining = new LensMining();
|
||||||
public static Lens lensMining;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an ore with a specific weight to the list of ores that the lens of the miner will generate inside of stone.
|
* Adds an ore with a specific weight to the list of ores that the lens of the miner will generate inside of stone.
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class ActuallyAdditions {
|
||||||
|
|
||||||
ActuallyAdditionsAPI.methodHandler = new MethodHandler();
|
ActuallyAdditionsAPI.methodHandler = new MethodHandler();
|
||||||
ActuallyAdditionsAPI.connectionHandler = new LaserRelayConnectionHandler();
|
ActuallyAdditionsAPI.connectionHandler = new LaserRelayConnectionHandler();
|
||||||
Lenses.init();
|
//Lenses.init();
|
||||||
// CompatUtil.registerCraftingTweaks();
|
// CompatUtil.registerCraftingTweaks();
|
||||||
event.enqueueWork(() -> CraftingHelper.register(TargetNBTIngredient.Serializer.NAME, TargetNBTIngredient.SERIALIZER));
|
event.enqueueWork(() -> CraftingHelper.register(TargetNBTIngredient.Serializer.NAME, TargetNBTIngredient.SERIALIZER));
|
||||||
|
|
||||||
|
|
|
@ -63,29 +63,29 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor) world.getBlockEntity(pos);
|
TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor) world.getBlockEntity(pos);
|
||||||
if (reconstructor != null) {
|
if (reconstructor != null) {
|
||||||
if (StackUtil.isValid(heldItem)) {
|
if (!heldItem.isEmpty()) {
|
||||||
Item item = heldItem.getItem();
|
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();
|
ItemStack toPut = heldItem.copy();
|
||||||
toPut.setCount(1);
|
toPut.setCount(1);
|
||||||
reconstructor.inv.setStackInSlot(0, toPut);
|
reconstructor.inv.setStackInSlot(0, toPut);
|
||||||
player.inventory.removeItem(player.inventory.selected, 1);
|
if (!player.isCreative()) {
|
||||||
}
|
heldItem.shrink(1);
|
||||||
//Shush, don't tell anyone!
|
}
|
||||||
else if (CommonConfig.Other.ELEVEN.get() == 11 && item == Items.MUSIC_DISC_11) {
|
return ActionResultType.CONSUME;
|
||||||
reconstructor.counter++;
|
|
||||||
reconstructor.setChanged();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ItemStack slot = reconstructor.inv.getStackInSlot(0);
|
ItemStack slot = reconstructor.inv.getStackInSlot(0);
|
||||||
if (StackUtil.isValid(slot)) {
|
if (!slot.isEmpty() && hand == Hand.MAIN_HAND) {
|
||||||
player.setItemInHand(hand, slot.copy());
|
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
|
@Nullable
|
||||||
|
|
|
@ -18,6 +18,7 @@ import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
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.TileEntityRenderer;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -25,6 +26,9 @@ import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.math.vector.Quaternion;
|
import net.minecraft.util.math.vector.Quaternion;
|
||||||
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class ReconstructorRenderer extends TileEntityRenderer<TileEntityAtomicReconstructor> {
|
public class ReconstructorRenderer extends TileEntityRenderer<TileEntityAtomicReconstructor> {
|
||||||
|
|
||||||
|
@ -33,62 +37,36 @@ public class ReconstructorRenderer extends TileEntityRenderer<TileEntityAtomicRe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
ItemStack stack = tile.inv.getStackInSlot(0);
|
||||||
//default color 0x1b6dff
|
//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) {
|
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);
|
AssetUtil.renderLaser(matrices, buffer, 0, 0, 0, rot, pitch, 5, 0, 0x1b6dff, 0.8f * tile.getProgress(), 0.2f);
|
||||||
tile.decTTL();
|
tile.decTTL();
|
||||||
}
|
}
|
||||||
if (!StackUtil.isValid(stack) || !(stack.getItem() instanceof ILensItem)) {
|
if (stack.isEmpty() || !(stack.getItem() instanceof ILensItem)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
matrices.pushPose();
|
matrices.pushPose();
|
||||||
matrices.translate(0.5F, 0.5F, 0.5F);
|
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());
|
matrices.mulPose(Vector3f.YP.rotationDegrees(rot));
|
||||||
int meta = 0; //state.getBlock().getMetaFromState(state); // TODO: [port][fix] this needs to be checking direction not meta
|
matrices.mulPose(Vector3f.XP.rotationDegrees(pitch));
|
||||||
if (meta == 0) {
|
|
||||||
matrices.translate(0F, -0.5F, 0F);
|
matrices.translate(0.0F, 0.0F, -0.5F);
|
||||||
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.scale(0.5F, 0.5F, 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();
|
matrices.popPose();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,15 +24,17 @@ import net.minecraft.util.Util;
|
||||||
import net.minecraft.util.math.vector.Quaternion;
|
import net.minecraft.util.math.vector.Quaternion;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class RenderDisplayStand extends TileEntityRenderer<TileEntityDisplayStand> {
|
public class RenderDisplayStand extends TileEntityRenderer<TileEntityDisplayStand> {
|
||||||
public RenderDisplayStand(TileEntityRendererDispatcher rendererDispatcherIn) {
|
public RenderDisplayStand(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||||
super(rendererDispatcherIn);
|
super(rendererDispatcherIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
ItemStack stack = tile.inv.getStackInSlot(0);
|
||||||
if (!StackUtil.isValid(stack)) {
|
if (stack.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,12 @@ import de.ellpeck.actuallyadditions.api.lens.LensConversion;
|
||||||
public final class Lenses {
|
public final class Lenses {
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
ActuallyAdditionsAPI.lensDefaultConversion = new LensConversion();
|
// ActuallyAdditionsAPI.lensDefaultConversion = new LensConversion();
|
||||||
ActuallyAdditionsAPI.lensDetonation = new LensDetonation();
|
// ActuallyAdditionsAPI.lensDetonation = new LensDetonation();
|
||||||
ActuallyAdditionsAPI.lensDeath = new LensDeath();
|
// ActuallyAdditionsAPI.lensDeath = new LensDeath();
|
||||||
ActuallyAdditionsAPI.lensEvenMoarDeath = new LensKiller();
|
// ActuallyAdditionsAPI.lensEvenMoarDeath = new LensKiller();
|
||||||
ActuallyAdditionsAPI.lensColor = new LensColor();
|
// ActuallyAdditionsAPI.lensColor = new LensColor();
|
||||||
ActuallyAdditionsAPI.lensDisenchanting = new LensDisenchanting();
|
// ActuallyAdditionsAPI.lensDisenchanting = new LensDisenchanting();
|
||||||
ActuallyAdditionsAPI.lensMining = new LensMining();
|
// ActuallyAdditionsAPI.lensMining = new LensMining();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,9 +132,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
||||||
if (item instanceof ILensItem) {
|
if (item instanceof ILensItem) {
|
||||||
return ((ILensItem) item).getLens();
|
return ((ILensItem) item).getLens();
|
||||||
}
|
}
|
||||||
return this.counter >= 500
|
return ActuallyAdditionsAPI.lensDefaultConversion;
|
||||||
? ActuallyAdditionsAPI.lensDisruption
|
|
||||||
: ActuallyAdditionsAPI.lensDefaultConversion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -76,7 +76,7 @@ public final class AssetUtil {
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public static void renderItemInWorld(ItemStack stack, int combinedLight, int combinedOverlay, MatrixStack matrices, IRenderTypeBuffer buffer) {
|
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(
|
Minecraft.getInstance().getItemRenderer().renderStatic(
|
||||||
stack, ItemCameraTransforms.TransformType.FIXED, combinedLight, combinedOverlay, matrices, buffer
|
stack, ItemCameraTransforms.TransformType.FIXED, combinedLight, combinedOverlay, matrices, buffer
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue