Compare commits

..

No commits in common. "ec2606f470b5bff6d3d00c4f79affe60e8014b40" and "68528b651f83fb860cae158f639114cd1e8ec9ac" have entirely different histories.

8 changed files with 115 additions and 66 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<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);
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);
// Interface Blocks

View file

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

View file

@ -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;
}
}

View file

@ -23,7 +23,6 @@ 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,7 +22,6 @@ 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) {
@ -39,9 +38,9 @@ public class RenderDisplayStand extends TileEntityRenderer<TileEntityDisplayStan
matrices.pushPose();
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.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
? 0.85F

View file

@ -26,7 +26,6 @@ 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) {
@ -41,9 +40,9 @@ public class RenderEmpowerer extends TileEntityRenderer<TileEntityEmpowerer> {
matrices.pushPose();
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.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
? 0.85F

View file

@ -62,6 +62,7 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer
@Override
public void writeSyncableNBT(CompoundNBT compound, NBTType type) {
super.writeSyncableNBT(compound, type);
if (type != NBTType.SAVE_BLOCK) {
compound.putInt("WaitTime", this.waitTime);
}
@ -70,11 +71,11 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer
compound.putInt("CheckY", this.checkY);
}
this.storage.writeToNBT(compound);
super.writeSyncableNBT(compound, type);
}
@Override
public void readSyncableNBT(CompoundNBT compound, NBTType type) {
super.readSyncableNBT(compound, type);
if (type != NBTType.SAVE_BLOCK) {
this.waitTime = compound.getInt("WaitTime");
}
@ -83,7 +84,6 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer
this.checkY = compound.getInt("CheckY");
}
this.storage.readFromNBT(compound);
super.readSyncableNBT(compound, type);
}
@Override

View file

@ -32,7 +32,6 @@ 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;
@ -422,25 +421,6 @@ 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};