mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-25 08:28:34 +01:00
Compare commits
No commits in common. "ec2606f470b5bff6d3d00c4f79affe60e8014b40" and "68528b651f83fb860cae158f639114cd1e8ec9ac" have entirely different histories.
ec2606f470
...
68528b651f
8 changed files with 115 additions and 66 deletions
|
@ -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));
|
public static final AABlockReg<BlockColoredLamp, AABlockItem, ?> LAMP_BLACK = new AABlockReg<>("lamp_black", BlockColoredLamp::new, (b) -> new AABlockItem(b, defaultBlockItemProperties));
|
||||||
|
|
||||||
// Empowerer / Display Stands
|
// Empowerer / Display Stands
|
||||||
public static final AABlockReg<BlockDisplayStand, AABlockItem, TileEntityEmpowerer> EMPOWERER = new AABlockReg<>("empowerer", () -> new BlockDisplayStand(true),
|
public static final AABlockReg<BlockEmpowerer, AABlockItem, TileEntityEmpowerer> EMPOWERER = new AABlockReg<>("empowerer", BlockEmpowerer::new,
|
||||||
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityEmpowerer::new);
|
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityEmpowerer::new);
|
||||||
public static final AABlockReg<BlockDisplayStand, AABlockItem, TileEntityDisplayStand> DISPLAY_STAND = new AABlockReg<>("display_stand", () -> new BlockDisplayStand(false),
|
public static final AABlockReg<BlockDisplayStand, AABlockItem, TileEntityDisplayStand> DISPLAY_STAND = new AABlockReg<>("display_stand", BlockDisplayStand::new,
|
||||||
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityDisplayStand::new);
|
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityDisplayStand::new);
|
||||||
|
|
||||||
// Interface Blocks
|
// Interface Blocks
|
||||||
|
|
|
@ -12,8 +12,6 @@ package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDisplayStand;
|
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.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
@ -33,60 +31,47 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class BlockDisplayStand extends BlockContainerBase {
|
public class BlockDisplayStand extends BlockContainerBase {
|
||||||
|
|
||||||
public BlockDisplayStand(boolean empowerer) {
|
public BlockDisplayStand() {
|
||||||
super(ActuallyBlocks.defaultPickProps(0));
|
super(ActuallyBlocks.defaultPickProps(0));
|
||||||
isEmpowerer = empowerer;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final boolean isEmpowerer;
|
|
||||||
|
|
||||||
public boolean isEmpowerer() {
|
|
||||||
return this.isEmpowerer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
//@Override
|
||||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
public TileEntity newBlockEntity(IBlockReader worldIn) {
|
||||||
return isEmpowerer? new TileEntityEmpowerer(): new TileEntityDisplayStand();
|
return new TileEntityDisplayStand();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasTileEntity(BlockState state) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||||
ItemStack heldItem = player.getItemInHand(hand);
|
ItemStack heldItem = player.getItemInHand(hand);
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
TileEntityInventoryBase stand = (TileEntityInventoryBase) world.getBlockEntity(pos);
|
TileEntityDisplayStand stand = (TileEntityDisplayStand) world.getBlockEntity(pos);
|
||||||
if (stand != null) {
|
if (stand != null) {
|
||||||
ItemStack stackThere = stand.inv.getStackInSlot(0);
|
ItemStack display = stand.inv.getStackInSlot(0);
|
||||||
if (!heldItem.isEmpty()) {
|
if (StackUtil.isValid(heldItem)) {
|
||||||
if (stackThere.isEmpty() && (!isEmpowerer || TileEntityEmpowerer.isPossibleInput(heldItem))) {
|
if (!StackUtil.isValid(display)) {
|
||||||
ItemStack toPut = heldItem.copy();
|
ItemStack toPut = heldItem.copy();
|
||||||
toPut.setCount(1);
|
toPut.setCount(1);
|
||||||
stand.inv.setStackInSlot(0, toPut);
|
stand.inv.setStackInSlot(0, toPut);
|
||||||
if (!player.isCreative()) {
|
if (!player.isCreative()) {
|
||||||
heldItem.shrink(1);
|
heldItem.shrink(1);
|
||||||
}
|
}
|
||||||
return ActionResultType.CONSUME;
|
return ActionResultType.PASS;
|
||||||
} else if (ItemUtil.canBeStacked(heldItem, stackThere)) {
|
} else if (ItemUtil.canBeStacked(heldItem, display)) {
|
||||||
int maxTransfer = Math.min(stackThere.getCount(), heldItem.getMaxStackSize() - heldItem.getCount());
|
int maxTransfer = Math.min(display.getCount(), heldItem.getMaxStackSize() - heldItem.getCount());
|
||||||
if (maxTransfer > 0) {
|
if (maxTransfer > 0) {
|
||||||
if (!player.isCreative())
|
heldItem.grow(maxTransfer);
|
||||||
player.setItemInHand(hand, StackUtil.grow(heldItem, maxTransfer));
|
ItemStack newDisplay = display.copy();
|
||||||
ItemStack newStackThere = stackThere.copy();
|
newDisplay.shrink(maxTransfer);
|
||||||
newStackThere.shrink(maxTransfer);
|
stand.inv.setStackInSlot(0, newDisplay);
|
||||||
stand.inv.setStackInSlot(0, newStackThere);
|
return ActionResultType.PASS;
|
||||||
return ActionResultType.CONSUME;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!stackThere.isEmpty() && hand == Hand.MAIN_HAND) {
|
if (StackUtil.isValid(display)) {
|
||||||
player.setItemInHand(hand, stackThere.copy());
|
player.setItemInHand(hand, display.copy());
|
||||||
stand.inv.setStackInSlot(0, ItemStack.EMPTY);
|
stand.inv.setStackInSlot(0, StackUtil.getEmpty());
|
||||||
return ActionResultType.CONSUME;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,7 +23,6 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
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.math.vector.Quaternion;
|
import net.minecraft.util.math.vector.Quaternion;
|
||||||
|
|
||||||
public class ReconstructorRenderer extends TileEntityRenderer<TileEntityAtomicReconstructor> {
|
public class ReconstructorRenderer extends TileEntityRenderer<TileEntityAtomicReconstructor> {
|
||||||
|
|
|
@ -22,7 +22,6 @@ import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Util;
|
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;
|
|
||||||
|
|
||||||
public class RenderDisplayStand extends TileEntityRenderer<TileEntityDisplayStand> {
|
public class RenderDisplayStand extends TileEntityRenderer<TileEntityDisplayStand> {
|
||||||
public RenderDisplayStand(TileEntityRendererDispatcher rendererDispatcherIn) {
|
public RenderDisplayStand(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||||
|
@ -39,9 +38,9 @@ public class RenderDisplayStand extends TileEntityRenderer<TileEntityDisplayStan
|
||||||
matrices.pushPose();
|
matrices.pushPose();
|
||||||
matrices.translate(0.5F, 1F, 0.5F);
|
matrices.translate(0.5F, 1F, 0.5F);
|
||||||
|
|
||||||
float boop = Util.getMillis() / 800F;
|
double boop = Util.getMillis() / 800D;
|
||||||
matrices.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D);
|
matrices.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D);
|
||||||
matrices.mulPose(Vector3f.YP.rotationDegrees(boop * 40F % 360.0F));
|
matrices.mulPose(new Quaternion((float) (boop * 40D % 360), 0, 1, 0));
|
||||||
|
|
||||||
float scale = stack.getItem() instanceof BlockItem
|
float scale = stack.getItem() instanceof BlockItem
|
||||||
? 0.85F
|
? 0.85F
|
||||||
|
|
|
@ -26,7 +26,6 @@ import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Util;
|
import net.minecraft.util.Util;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.vector.Quaternion;
|
import net.minecraft.util.math.vector.Quaternion;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
|
||||||
|
|
||||||
public class RenderEmpowerer extends TileEntityRenderer<TileEntityEmpowerer> {
|
public class RenderEmpowerer extends TileEntityRenderer<TileEntityEmpowerer> {
|
||||||
public RenderEmpowerer(TileEntityRendererDispatcher rendererDispatcherIn) {
|
public RenderEmpowerer(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||||
|
@ -41,9 +40,9 @@ public class RenderEmpowerer extends TileEntityRenderer<TileEntityEmpowerer> {
|
||||||
matrices.pushPose();
|
matrices.pushPose();
|
||||||
matrices.translate(0.5F, 1F, 0.5F);
|
matrices.translate(0.5F, 1F, 0.5F);
|
||||||
|
|
||||||
float boop = Util.getMillis() / 800F;
|
double boop = Util.getMillis() / 800D;
|
||||||
matrices.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D);
|
matrices.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D);
|
||||||
matrices.mulPose(Vector3f.YP.rotationDegrees(boop * 40F % 360.0F));
|
matrices.mulPose(new Quaternion((float) (boop * 40D % 360), 0, 1, 0)); // TODO: [port] might not work
|
||||||
|
|
||||||
float scale = stack.getItem() instanceof BlockItem
|
float scale = stack.getItem() instanceof BlockItem
|
||||||
? 0.85F
|
? 0.85F
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeSyncableNBT(CompoundNBT compound, NBTType type) {
|
public void writeSyncableNBT(CompoundNBT compound, NBTType type) {
|
||||||
|
super.writeSyncableNBT(compound, type);
|
||||||
if (type != NBTType.SAVE_BLOCK) {
|
if (type != NBTType.SAVE_BLOCK) {
|
||||||
compound.putInt("WaitTime", this.waitTime);
|
compound.putInt("WaitTime", this.waitTime);
|
||||||
}
|
}
|
||||||
|
@ -70,11 +71,11 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer
|
||||||
compound.putInt("CheckY", this.checkY);
|
compound.putInt("CheckY", this.checkY);
|
||||||
}
|
}
|
||||||
this.storage.writeToNBT(compound);
|
this.storage.writeToNBT(compound);
|
||||||
super.writeSyncableNBT(compound, type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readSyncableNBT(CompoundNBT compound, NBTType type) {
|
public void readSyncableNBT(CompoundNBT compound, NBTType type) {
|
||||||
|
super.readSyncableNBT(compound, type);
|
||||||
if (type != NBTType.SAVE_BLOCK) {
|
if (type != NBTType.SAVE_BLOCK) {
|
||||||
this.waitTime = compound.getInt("WaitTime");
|
this.waitTime = compound.getInt("WaitTime");
|
||||||
}
|
}
|
||||||
|
@ -83,7 +84,6 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer
|
||||||
this.checkY = compound.getInt("CheckY");
|
this.checkY = compound.getInt("CheckY");
|
||||||
}
|
}
|
||||||
this.storage.readFromNBT(compound);
|
this.storage.readFromNBT(compound);
|
||||||
super.readSyncableNBT(compound, type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,7 +32,6 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.particles.IParticleData;
|
import net.minecraft.particles.IParticleData;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.NonNullList;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
import net.minecraft.util.math.vector.Matrix4f;
|
||||||
|
@ -422,25 +421,6 @@ public final class AssetUtil {
|
||||||
GlStateManager._popMatrix();
|
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) {
|
public static float[] getWheelColor(float pos) {
|
||||||
if (pos < 85.0f) {
|
if (pos < 85.0f) {
|
||||||
return new float[]{pos * 3.0F, 255.0f - pos * 3.0f, 0.0f};
|
return new float[]{pos * 3.0F, 255.0f - pos * 3.0f, 0.0f};
|
||||||
|
|
Loading…
Reference in a new issue