Just display stand things...

This commit is contained in:
Flanks255 2022-02-15 19:36:31 -06:00
parent 68528b651f
commit 80b3d7b64f
7 changed files with 64 additions and 113 deletions

View file

@ -152,9 +152,9 @@ public final class ActuallyBlocks {
public static final AABlockReg<BlockColoredLamp, AABlockItem, ?> LAMP_BLACK = new AABlockReg<>("lamp_black", BlockColoredLamp::new, (b) -> new AABlockItem(b, defaultBlockItemProperties));
// Empowerer / Display Stands
public static final AABlockReg<BlockEmpowerer, AABlockItem, TileEntityEmpowerer> EMPOWERER = new AABlockReg<>("empowerer", BlockEmpowerer::new,
public static final AABlockReg<BlockDisplayStand, AABlockItem, TileEntityEmpowerer> EMPOWERER = new AABlockReg<>("empowerer", () -> new BlockDisplayStand(true),
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityEmpowerer::new);
public static final AABlockReg<BlockDisplayStand, AABlockItem, TileEntityDisplayStand> DISPLAY_STAND = new AABlockReg<>("display_stand", BlockDisplayStand::new,
public static final AABlockReg<BlockDisplayStand, AABlockItem, TileEntityDisplayStand> DISPLAY_STAND = new AABlockReg<>("display_stand", () -> new BlockDisplayStand(false),
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityDisplayStand::new);
// Interface Blocks

View file

@ -12,6 +12,8 @@ package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDisplayStand;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEmpowerer;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.BlockState;
@ -31,47 +33,60 @@ import javax.annotation.Nullable;
public class BlockDisplayStand extends BlockContainerBase {
public BlockDisplayStand() {
public BlockDisplayStand(boolean empowerer) {
super(ActuallyBlocks.defaultPickProps(0));
isEmpowerer = empowerer;
}
private final boolean isEmpowerer;
public boolean isEmpowerer() {
return this.isEmpowerer;
}
@Nullable
//@Override
public TileEntity newBlockEntity(IBlockReader worldIn) {
return new TileEntityDisplayStand();
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return isEmpowerer? new TileEntityEmpowerer(): new TileEntityDisplayStand();
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Override
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
ItemStack heldItem = player.getItemInHand(hand);
if (!world.isClientSide) {
TileEntityDisplayStand stand = (TileEntityDisplayStand) world.getBlockEntity(pos);
TileEntityInventoryBase stand = (TileEntityInventoryBase) world.getBlockEntity(pos);
if (stand != null) {
ItemStack display = stand.inv.getStackInSlot(0);
if (StackUtil.isValid(heldItem)) {
if (!StackUtil.isValid(display)) {
ItemStack stackThere = stand.inv.getStackInSlot(0);
if (!heldItem.isEmpty()) {
if (stackThere.isEmpty() && (!isEmpowerer || TileEntityEmpowerer.isPossibleInput(heldItem))) {
ItemStack toPut = heldItem.copy();
toPut.setCount(1);
stand.inv.setStackInSlot(0, toPut);
if (!player.isCreative()) {
heldItem.shrink(1);
}
return ActionResultType.PASS;
} else if (ItemUtil.canBeStacked(heldItem, display)) {
int maxTransfer = Math.min(display.getCount(), heldItem.getMaxStackSize() - heldItem.getCount());
return ActionResultType.CONSUME;
} else if (ItemUtil.canBeStacked(heldItem, stackThere)) {
int maxTransfer = Math.min(stackThere.getCount(), heldItem.getMaxStackSize() - heldItem.getCount());
if (maxTransfer > 0) {
heldItem.grow(maxTransfer);
ItemStack newDisplay = display.copy();
newDisplay.shrink(maxTransfer);
stand.inv.setStackInSlot(0, newDisplay);
return ActionResultType.PASS;
if (!player.isCreative())
player.setItemInHand(hand, StackUtil.grow(heldItem, maxTransfer));
ItemStack newStackThere = stackThere.copy();
newStackThere.shrink(maxTransfer);
stand.inv.setStackInSlot(0, newStackThere);
return ActionResultType.CONSUME;
}
}
} else {
if (StackUtil.isValid(display)) {
player.setItemInHand(hand, display.copy());
stand.inv.setStackInSlot(0, StackUtil.getEmpty());
return ActionResultType.PASS;
if (!stackThere.isEmpty() && hand == Hand.MAIN_HAND) {
player.setItemInHand(hand, stackThere.copy());
stand.inv.setStackInSlot(0, ItemStack.EMPTY);
return ActionResultType.CONSUME;
}
}
}

View file

@ -1,87 +0,0 @@
/*
* This file ("BlockEmpowerer.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEmpowerer;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import javax.annotation.Nullable;
public class BlockEmpowerer extends BlockContainerBase {
public BlockEmpowerer() {
super(ActuallyBlocks.defaultPickProps(0));
}
@Nullable
//@Override
public TileEntity newBlockEntity(IBlockReader worldIn) {
return new TileEntityEmpowerer();
}
@Override
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
ItemStack heldItem = player.getItemInHand(hand);
if (!world.isClientSide) {
TileEntityEmpowerer empowerer = (TileEntityEmpowerer) world.getBlockEntity(pos);
if (empowerer != null) {
ItemStack stackThere = empowerer.inv.getStackInSlot(0);
if (StackUtil.isValid(heldItem)) {
if (!StackUtil.isValid(stackThere) && TileEntityEmpowerer.isPossibleInput(heldItem)) {
ItemStack toPut = heldItem.copy();
toPut.setCount(1);
empowerer.inv.setStackInSlot(0, toPut);
if (!player.isCreative()) {
heldItem.shrink(1);
}
return ActionResultType.PASS;
} else if (ItemUtil.canBeStacked(heldItem, stackThere)) {
int maxTransfer = Math.min(stackThere.getCount(), heldItem.getMaxStackSize() - heldItem.getCount());
if (maxTransfer > 0) {
player.setItemInHand(hand, StackUtil.grow(heldItem, maxTransfer));
ItemStack newStackThere = stackThere.copy();
newStackThere = StackUtil.shrink(newStackThere, maxTransfer);
empowerer.inv.setStackInSlot(0, newStackThere);
return ActionResultType.PASS;
}
}
} else {
if (StackUtil.isValid(stackThere)) {
player.setItemInHand(hand, stackThere.copy());
empowerer.inv.setStackInSlot(0, StackUtil.getEmpty());
return ActionResultType.PASS;
}
}
}
return ActionResultType.FAIL;
}
return ActionResultType.PASS;
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return Shapes.EMPOWERER_SHAPE;
}
}

View file

@ -23,6 +23,7 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.ItemStack;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.vector.Quaternion;
public class ReconstructorRenderer extends TileEntityRenderer<TileEntityAtomicReconstructor> {

View file

@ -22,6 +22,7 @@ import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Util;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3f;
public class RenderDisplayStand extends TileEntityRenderer<TileEntityDisplayStand> {
public RenderDisplayStand(TileEntityRendererDispatcher rendererDispatcherIn) {
@ -38,9 +39,9 @@ public class RenderDisplayStand extends TileEntityRenderer<TileEntityDisplayStan
matrices.pushPose();
matrices.translate(0.5F, 1F, 0.5F);
double boop = Util.getMillis() / 800D;
float boop = Util.getMillis() / 800F;
matrices.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D);
matrices.mulPose(new Quaternion((float) (boop * 40D % 360), 0, 1, 0));
matrices.mulPose(Vector3f.YP.rotationDegrees(boop * 40F % 360.0F));
float scale = stack.getItem() instanceof BlockItem
? 0.85F

View file

@ -26,6 +26,7 @@ import net.minecraft.util.Direction;
import net.minecraft.util.Util;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3f;
public class RenderEmpowerer extends TileEntityRenderer<TileEntityEmpowerer> {
public RenderEmpowerer(TileEntityRendererDispatcher rendererDispatcherIn) {
@ -40,9 +41,9 @@ public class RenderEmpowerer extends TileEntityRenderer<TileEntityEmpowerer> {
matrices.pushPose();
matrices.translate(0.5F, 1F, 0.5F);
double boop = Util.getMillis() / 800D;
float boop = Util.getMillis() / 800F;
matrices.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D);
matrices.mulPose(new Quaternion((float) (boop * 40D % 360), 0, 1, 0)); // TODO: [port] might not work
matrices.mulPose(Vector3f.YP.rotationDegrees(boop * 40F % 360.0F));
float scale = stack.getItem() instanceof BlockItem
? 0.85F

View file

@ -32,6 +32,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.particles.IParticleData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Matrix4f;
@ -421,6 +422,25 @@ public final class AssetUtil {
GlStateManager._popMatrix();
}
@OnlyIn(Dist.CLIENT)
public static void renderTextInWorld(MatrixStack matrixStack, double offsetX, double offsetY, double offsetZ, NonNullList<String> text, int color) {
matrixStack.pushPose();
matrixStack.translate(offsetX,offsetY,offsetZ);
matrixStack.scale(-1, -1, 1);
matrixStack.mulPose(Vector3f.YP.rotationDegrees(Minecraft.getInstance().cameraEntity.yRot));
matrixStack.scale(0.01F, 0.01F, 0.01F);
FontRenderer font = Minecraft.getInstance().font;
int y = 0;
for (String s : text) {
font.draw(matrixStack, s, 0, y, color);
y+= 10;
}
matrixStack.popPose();
}
public static float[] getWheelColor(float pos) {
if (pos < 85.0f) {
return new float[]{pos * 3.0F, 255.0f - pos * 3.0f, 0.0f};