mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-21 15:03:30 +01:00
* Fixed Farmer not playing well with non vanilla farmland.
* Added the ability to change the farmers work area with a compass. * Code cleaning.
This commit is contained in:
parent
95977167e3
commit
b66af8446c
18 changed files with 122 additions and 297 deletions
|
@ -1,3 +1,7 @@
|
|||
# 1.3.11+mc1.21.1
|
||||
* Fixed Farmer not playing well with non vanilla farmland.
|
||||
* Added the ability to change the farmers work area with a compass.
|
||||
|
||||
# 1.3.10+mc1.21.1
|
||||
* Fixed Fluid placer not being harvestable.
|
||||
* PR #1438, Added config to disable energy overlay.
|
||||
|
|
|
@ -4,7 +4,7 @@ org.gradle.parallel=true
|
|||
org.gradle.caching=true
|
||||
org.gradle.configuration-cache=false
|
||||
|
||||
mod_version=1.3.10
|
||||
mod_version=1.3.11
|
||||
|
||||
# Forge
|
||||
game_version=1.21.1
|
||||
|
|
|
@ -40,7 +40,6 @@ import de.ellpeck.actuallyadditions.mod.util.ResourceReloader;
|
|||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
|
@ -139,10 +138,12 @@ public class ActuallyAdditions {
|
|||
|
||||
private void onConfigReload(ModConfigEvent event) {
|
||||
if (event.getConfig().getType() == ModConfig.Type.COMMON) {
|
||||
Item item1 = BuiltInRegistries.ITEM.get(ResourceLocation.tryParse(CommonConfig.Other.REDSTONECONFIGURATOR.get()));
|
||||
Item item2 = BuiltInRegistries.ITEM.get(ResourceLocation.tryParse(CommonConfig.Other.RELAYCONFIGURATOR.get()));
|
||||
CommonConfig.Other.redstoneConfigureItem = item1 != null ? item1 : Items.AIR;
|
||||
CommonConfig.Other.relayConfigureItem = item2 != null ? item2 : Items.AIR;
|
||||
CommonConfig.Other.redstoneConfigureItem =
|
||||
BuiltInRegistries.ITEM.getOptional(ResourceLocation.tryParse(CommonConfig.Other.REDSTONECONFIGURATOR.get())).orElse(Items.AIR);
|
||||
CommonConfig.Other.relayConfigureItem =
|
||||
BuiltInRegistries.ITEM.getOptional(ResourceLocation.tryParse(CommonConfig.Other.RELAYCONFIGURATOR.get())).orElse(Items.AIR);
|
||||
CommonConfig.Other.farmerConfigureItem =
|
||||
BuiltInRegistries.ITEM.getOptional(ResourceLocation.tryParse(CommonConfig.Other.FARMERCONFIG.get())).orElse(Items.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,24 +90,6 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im
|
|||
return ItemInteractionResult.CONSUME;
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
switch (state.getValue(FACING)) {
|
||||
case UP:
|
||||
return VoxelShapes.AtomicReconstructorShapes.SHAPE_U;
|
||||
case DOWN:
|
||||
return VoxelShapes.AtomicReconstructorShapes.SHAPE_D;
|
||||
case EAST:
|
||||
return VoxelShapes.AtomicReconstructorShapes.SHAPE_E;
|
||||
case SOUTH:
|
||||
return VoxelShapes.AtomicReconstructorShapes.SHAPE_S;
|
||||
case WEST:
|
||||
return VoxelShapes.AtomicReconstructorShapes.SHAPE_W;
|
||||
default:
|
||||
return VoxelShapes.AtomicReconstructorShapes.SHAPE_N;
|
||||
}
|
||||
}*/
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
|
@ -139,7 +121,7 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im
|
|||
|
||||
|
||||
@Override
|
||||
public void appendHoverText(@Nonnull ItemStack pStack, @Nullable TooltipContext context, @Nonnull List<Component> pTooltip, @Nonnull TooltipFlag pFlag) {
|
||||
public void appendHoverText(@Nonnull ItemStack pStack, @Nonnull TooltipContext context, @Nonnull List<Component> pTooltip, @Nonnull TooltipFlag pFlag) {
|
||||
super.appendHoverText(pStack, context, pTooltip, pFlag);
|
||||
|
||||
long sysTime = System.currentTimeMillis();
|
||||
|
@ -169,11 +151,7 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im
|
|||
|
||||
@Override
|
||||
protected boolean updateCustomBlockEntityTag(BlockPos pPos, Level pLevel, @Nullable Player pPlayer, ItemStack pStack, BlockState pState) {
|
||||
boolean ret = super.updateCustomBlockEntityTag(pPos, pLevel, pPlayer, pStack, pState);
|
||||
|
||||
|
||||
|
||||
return ret;
|
||||
return super.updateCustomBlockEntityTag(pPos, pLevel, pPlayer, pStack, pState);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,18 +100,4 @@ public class BlockCrusher extends BlockContainerBase {
|
|||
? 12
|
||||
: 0;
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
switch (state.getValue(HORIZONTAL_FACING)) {
|
||||
case EAST:
|
||||
return VoxelShapes.GrinderShapes.SHAPE_E;
|
||||
case SOUTH:
|
||||
return VoxelShapes.GrinderShapes.SHAPE_S;
|
||||
case WEST:
|
||||
return VoxelShapes.GrinderShapes.SHAPE_W;
|
||||
default:
|
||||
return VoxelShapes.GrinderShapes.SHAPE_N;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -50,22 +50,4 @@ public class BlockDropper extends FullyDirectionalBlock.Container {
|
|||
|
||||
return this.openGui(world, player, pos, TileEntityDropper.class);
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
switch (state.getValue(FACING)) {
|
||||
case UP:
|
||||
return VoxelShapes.BlockBreakerShapes.SHAPE_U;
|
||||
case DOWN:
|
||||
return VoxelShapes.BlockBreakerShapes.SHAPE_D;
|
||||
case EAST:
|
||||
return VoxelShapes.BlockBreakerShapes.SHAPE_E;
|
||||
case SOUTH:
|
||||
return VoxelShapes.BlockBreakerShapes.SHAPE_S;
|
||||
case WEST:
|
||||
return VoxelShapes.BlockBreakerShapes.SHAPE_W;
|
||||
default:
|
||||
return VoxelShapes.BlockBreakerShapes.SHAPE_N;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -58,12 +58,4 @@ public class BlockEnergizer extends BlockContainerBase {
|
|||
return this.openGui(world, player, pos, TileEntityEnervator.class);
|
||||
}
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
if (this.isEnergizer) {
|
||||
return VoxelShapes.ENERGIZER_SHAPE;
|
||||
}
|
||||
return VoxelShapes.ENERVATOR_SHAPE;
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -11,10 +11,16 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.FarmerHud;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud;
|
||||
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFarmer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.ItemInteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
@ -25,7 +31,8 @@ import net.minecraft.world.phys.BlockHitResult;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockFarmer extends DirectionalBlock.Container {
|
||||
public class BlockFarmer extends DirectionalBlock.Container implements IHudDisplay {
|
||||
private static final IBlockHud HUD = new FarmerHud();
|
||||
|
||||
public BlockFarmer() {
|
||||
super(ActuallyBlocks.defaultPickProps().sound(SoundType.METAL));
|
||||
|
@ -48,17 +55,20 @@ public class BlockFarmer extends DirectionalBlock.Container {
|
|||
return this.openGui(world, player, pos, TileEntityFarmer.class);
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
switch (state.getValue(FACING)) {
|
||||
case EAST:
|
||||
return VoxelShapes.FarmerShapes.SHAPE_E;
|
||||
case SOUTH:
|
||||
return VoxelShapes.FarmerShapes.SHAPE_S;
|
||||
case WEST:
|
||||
return VoxelShapes.FarmerShapes.SHAPE_W;
|
||||
default:
|
||||
return VoxelShapes.FarmerShapes.SHAPE_N;
|
||||
@Override
|
||||
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
|
||||
ItemStack heldItem = player.getItemInHand(hand);
|
||||
BlockEntity tile = level.getBlockEntity(pos);
|
||||
if (heldItem.getItem() == CommonConfig.Other.farmerConfigureItem && tile instanceof TileEntityFarmer farmer) {
|
||||
farmer.cycleArea();
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
}*/
|
||||
|
||||
return super.useItemOn(stack, state, level, pos, player, hand, hitResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockHud getHud() {
|
||||
return HUD;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,9 +46,4 @@ public class BlockFeeder extends BlockContainerBase {
|
|||
protected InteractionResult useWithoutItem(BlockState pState, Level world, BlockPos pos, Player player, BlockHitResult pHitResult) {
|
||||
return this.openGui(world, player, pos, TileEntityFeeder.class);
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
return VoxelShapes.FEEDER_SHAPE;
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -69,23 +69,4 @@ public class BlockFluidCollector extends FullyDirectionalBlock.Container {
|
|||
|
||||
return this.openGui2(world, player, pos, TileEntityFluidCollector.class);
|
||||
}
|
||||
|
||||
/* @Nonnull
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, @Nonnull BlockGetter worldIn, @Nonnull BlockPos pos, @Nonnull CollisionContext context) {
|
||||
switch (state.getValue(FACING)) {
|
||||
case UP:
|
||||
return VoxelShapes.FluidCollectorShapes.SHAPE_U;
|
||||
case DOWN:
|
||||
return VoxelShapes.FluidCollectorShapes.SHAPE_D;
|
||||
case EAST:
|
||||
return VoxelShapes.FluidCollectorShapes.SHAPE_E;
|
||||
case SOUTH:
|
||||
return VoxelShapes.FluidCollectorShapes.SHAPE_S;
|
||||
case WEST:
|
||||
return VoxelShapes.FluidCollectorShapes.SHAPE_W;
|
||||
default:
|
||||
return VoxelShapes.FluidCollectorShapes.SHAPE_N;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -1,108 +0,0 @@
|
|||
///*
|
||||
// * This file ("BlockMisc.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.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
//import net.minecraft.block.Block;
|
||||
//import net.minecraft.block.material.Material;
|
||||
//import net.minecraft.block.properties.PropertyEnum;
|
||||
//import net.minecraft.block.state.BlockStateContainer;
|
||||
//import net.minecraft.creativetab.CreativeTabs;
|
||||
//import net.minecraft.item.EnumRarity;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraft.util.NonNullList;
|
||||
//
|
||||
//public class BlockMisc extends BlockBase {
|
||||
//
|
||||
// public static final TheMiscBlocks[] ALL_MISC_BLOCKS = TheMiscBlocks.values();
|
||||
// public static final PropertyEnum<TheMiscBlocks> TYPE = PropertyEnum.create("type", TheMiscBlocks.class);
|
||||
//
|
||||
// public BlockMisc() {
|
||||
// super(Material.ROCK);
|
||||
// this.setHardness(1.5F);
|
||||
// this.setResistance(10.0F);
|
||||
// this.setHarvestLevel("pickaxe", 1);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int damageDropped(BlockState state) {
|
||||
// return this.getMetaFromState(state);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
// for (int j = 0; j < ALL_MISC_BLOCKS.length; j++) {
|
||||
// list.add(new ItemStack(this, 1, j));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected ItemBlockBase getItemBlock() {
|
||||
// return new TheItemBlock(this);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void registerRendering() {
|
||||
// for (int i = 0; i < ALL_MISC_BLOCKS.length; i++) {
|
||||
// ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName() + "=" + ALL_MISC_BLOCKS[i].name);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public EnumRarity getRarity(ItemStack stack) {
|
||||
// return stack.getItemDamage() >= ALL_MISC_BLOCKS.length
|
||||
// ? EnumRarity.COMMON
|
||||
// : ALL_MISC_BLOCKS[stack.getItemDamage()].rarity;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public BlockState getStateFromMeta(int meta) {
|
||||
// return this.getDefaultState().withProperty(TYPE, TheMiscBlocks.values()[meta]);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getMetaFromState(BlockState state) {
|
||||
// return state.getValue(TYPE).ordinal();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected BlockStateContainer createBlockState() {
|
||||
// return new BlockStateContainer(this, TYPE);
|
||||
// }
|
||||
//
|
||||
// public static class TheItemBlock extends ItemBlockBase {
|
||||
//
|
||||
// public TheItemBlock(Block block) {
|
||||
// super(block);
|
||||
// this.setHasSubtypes(true);
|
||||
// this.setMaxDamage(0);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getTranslationKey(ItemStack stack) {
|
||||
// return stack.getItemDamage() >= ALL_MISC_BLOCKS.length
|
||||
// ? StringUtil.BUGGED_ITEM_NAME
|
||||
// : this.getTranslationKey() + "_" + ALL_MISC_BLOCKS[stack.getItemDamage()].name;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getItemBurnTime(ItemStack stack) {
|
||||
// if (stack.getMetadata() == TheMiscBlocks.CHARCOAL_BLOCK.ordinal()) {
|
||||
// return 16000;
|
||||
// }
|
||||
// return super.getItemBurnTime(stack);
|
||||
// }
|
||||
// }
|
||||
//}
|
|
@ -22,7 +22,6 @@ import net.minecraft.world.InteractionHand;
|
|||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.ItemInteractionResult;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -38,7 +37,6 @@ import net.neoforged.neoforge.fluids.FluidUtil;
|
|||
import net.neoforged.neoforge.fluids.capability.templates.FluidTank;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class BlockContainerBase extends Block implements EntityBlock {
|
||||
public BlockContainerBase(Properties properties) {
|
||||
|
@ -73,7 +71,7 @@ public abstract class BlockContainerBase extends Block implements EntityBlock {
|
|||
if (!world.isClientSide) {
|
||||
BlockEntity aTile = world.getBlockEntity(position);
|
||||
if (aTile instanceof TileEntityInventoryBase tile) {
|
||||
if (tile.inv.getSlots() > 0) {
|
||||
if (tile.inv.getSlots() > 0) {
|
||||
for (int i = 0; i < tile.inv.getSlots(); i++) {
|
||||
this.dropSlotFromInventory(i, tile, world, position);
|
||||
}
|
||||
|
@ -142,7 +140,7 @@ public abstract class BlockContainerBase extends Block implements EntityBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChange(BlockState state, LevelReader world, BlockPos pos, BlockPos neighbor) {
|
||||
public void onNeighborChange(@Nonnull BlockState state, @Nonnull LevelReader world, @Nonnull BlockPos pos, @Nonnull BlockPos neighbor) {
|
||||
super.onNeighborChange(state, world, pos, neighbor);
|
||||
if (world instanceof Level) { //TODO what?
|
||||
this.neighborsChangedCustom((Level) world, pos);
|
||||
|
@ -181,19 +179,9 @@ public abstract class BlockContainerBase extends Block implements EntityBlock {
|
|||
this.updateRedstoneState(worldIn, pos);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||
// if (stack.hasTag()) {
|
||||
// BlockEntity tile = world.getBlockEntity(pos);
|
||||
// if (tile instanceof TileEntityBase base) {
|
||||
// CompoundTag compound = stack.get(DataComponents.BLOCK_ENTITY_DATA).getCompound("Data");
|
||||
// base.readSyncableNBT(compound, world.registryAccess(), TileEntityBase.NBTType.SAVE_BLOCK); TODO: Check if this is still required
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState playerWillDestroy(@Nonnull Level world, @Nonnull BlockPos pos, @Nonnull BlockState state, Player player) {
|
||||
public BlockState playerWillDestroy(@Nonnull Level world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull Player player) {
|
||||
BlockState theState = super.playerWillDestroy(world, pos, state, player);
|
||||
if (!player.isCreative() && world.getBlockEntity(pos) instanceof TileEntityBase tileBase && tileBase.stopFromDropping) {
|
||||
if (!world.isClientSide)
|
||||
|
@ -204,12 +192,12 @@ public abstract class BlockContainerBase extends Block implements EntityBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAnalogOutputSignal(BlockState state) {
|
||||
public boolean hasAnalogOutputSignal(@Nonnull BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAnalogOutputSignal(BlockState state, Level world, BlockPos pos) {
|
||||
public int getAnalogOutputSignal(@Nonnull BlockState state, Level world, @Nonnull BlockPos pos) {
|
||||
BlockEntity tile = world.getBlockEntity(pos);
|
||||
if (tile instanceof TileEntityBase) {
|
||||
return ((TileEntityBase) tile).getComparatorStrength();
|
||||
|
@ -217,62 +205,14 @@ public abstract class BlockContainerBase extends Block implements EntityBlock {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// TODO: [port]: come back and fix this
|
||||
|
||||
// @Override
|
||||
// public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, BlockState state, int fortune) {
|
||||
// TileEntity tile = world.getTileEntity(pos);
|
||||
// if (tile instanceof TileEntityBase) {
|
||||
// TileEntityBase base = (TileEntityBase) tile;
|
||||
// if (!base.stopFromDropping) {
|
||||
// CompoundNBT data = new CompoundNBT();
|
||||
// base.writeSyncableNBT(data, TileEntityBase.NBTType.SAVE_BLOCK);
|
||||
//
|
||||
// //Remove unnecessarily saved default values to avoid unstackability
|
||||
// List<String> keysToRemove = new ArrayList<>();
|
||||
// for (String key : data.getKeySet()) {
|
||||
// NBTBase tag = data.getTag(key);
|
||||
// //Remove only ints because they are the most common ones
|
||||
// //Add else if below here to remove more types
|
||||
// if (tag instanceof NBTTagInt) {
|
||||
// if (((NBTTagInt) tag).getInt() == 0) {
|
||||
// keysToRemove.add(key);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for (String key : keysToRemove) {
|
||||
// data.removeTag(key);
|
||||
// }
|
||||
//
|
||||
// ItemStack stack = new ItemStack(this.getItemDropped(state, tile.getWorld().rand, fortune), 1, this.damageDropped(state));
|
||||
// if (!data.isEmpty()) {
|
||||
// stack.setTagCompound(new CompoundNBT());
|
||||
// stack.getTagCompound().setTag("Data", data);
|
||||
// }
|
||||
//
|
||||
// drops.add(stack);
|
||||
// }
|
||||
// } else {
|
||||
// super.getDrops(drops, world, pos, state, fortune);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// TODO: [port]: eval
|
||||
|
||||
// @Override
|
||||
// public EnumBlockRenderType getRenderType(BlockState state) {
|
||||
// return EnumBlockRenderType.MODEL;
|
||||
// }
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState pState) {
|
||||
public RenderShape getRenderShape(@Nonnull BlockState pState) {
|
||||
return RenderShape.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
public void onRemove(BlockState state, @Nonnull Level world, @Nonnull BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
if (this.shouldDropInventory(world, pos)) {
|
||||
this.dropInventory(world, pos);
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks.blockhuds;
|
||||
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFarmer;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
|
||||
public class FarmerHud implements IBlockHud {
|
||||
@Override
|
||||
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
||||
if (!(rayCast instanceof BlockHitResult) || minecraft.level == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockEntity tile = minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos());
|
||||
if (tile instanceof TileEntityFarmer farmer) {
|
||||
guiGraphics.drawString(minecraft.font, Component.translatable("info.actuallyadditions.farmer.area", farmer.getArea(), farmer.getArea()), (int) (resolution.getGuiScaledWidth() / 2.0f + 5), (int) (resolution.getGuiScaledHeight() / 2.0f - 0), 0xFFFFFF);
|
||||
|
||||
Component message;
|
||||
if (!stack.isEmpty() && stack.getItem() == CommonConfig.Other.farmerConfigureItem) {
|
||||
message = Component.translatable("info.actuallyadditions.farmer.validItem").withStyle(ChatFormatting.GREEN);
|
||||
} else {
|
||||
message = Component.translatable("info.actuallyadditions.farmer.invalidItem", Component.translatable(CommonConfig.Other.farmerConfigureItem.asItem().getDescriptionId()).getString()).withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC);
|
||||
}
|
||||
guiGraphics.drawString(minecraft.font, message, (int) (minecraft.getWindow().getGuiScaledWidth() / 2f + 5), (int) (minecraft.getWindow().getGuiScaledHeight() / 2f + 15), 0xFFFFFF);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,8 +24,8 @@ public class ReconstructorHud implements IBlockHud {
|
|||
}
|
||||
|
||||
BlockEntity tile = minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos());
|
||||
if (tile instanceof TileEntityAtomicReconstructor) {
|
||||
ItemStack slot = ((TileEntityAtomicReconstructor) tile).inv.getStackInSlot(0);
|
||||
if (tile instanceof TileEntityAtomicReconstructor laser) {
|
||||
ItemStack slot = laser.inv.getStackInSlot(0);
|
||||
Component lens_name;
|
||||
if (slot.isEmpty()) {
|
||||
lens_name = Component.translatable("info.actuallyadditions.nolens");
|
||||
|
|
|
@ -107,8 +107,10 @@ public class CommonConfig {
|
|||
public static ModConfigSpec.BooleanValue MOST_BLAND_PERSON_EVER;
|
||||
public static ModConfigSpec.ConfigValue<String> REDSTONECONFIGURATOR;
|
||||
public static ModConfigSpec.ConfigValue<String> RELAYCONFIGURATOR;
|
||||
public static ModConfigSpec.ConfigValue<String> FARMERCONFIG;
|
||||
public static Item redstoneConfigureItem = Items.AIR;
|
||||
public static Item relayConfigureItem = Items.AIR;
|
||||
public static Item farmerConfigureItem = Items.AIR;
|
||||
|
||||
|
||||
public static void build() {
|
||||
|
@ -164,6 +166,7 @@ public class CommonConfig {
|
|||
|
||||
REDSTONECONFIGURATOR = BUILDER.comment("define the item used to configure Redstone Mode").define("redstoneConfigurator", "minecraft:redstone_torch");
|
||||
RELAYCONFIGURATOR = BUILDER.comment("define the item used to configure Direction in laser relays").define("relayConfigurator", "minecraft:compass");
|
||||
FARMERCONFIG = BUILDER.comment("define the item used to configure the area in a farmer").define("farmerConfigurator", "minecraft:compass");
|
||||
|
||||
BUILDER.pop();
|
||||
}
|
||||
|
|
|
@ -26,10 +26,7 @@ import net.minecraft.world.item.Item;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.CropBlock;
|
||||
import net.minecraft.world.level.block.StemBlock;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
|
@ -47,8 +44,8 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
|
|||
public static boolean defaultPlant(Level world, BlockPos pos, BlockState toPlant, IFarmer farmer, int use) {
|
||||
if (toPlant != null) {
|
||||
BlockPos farmland = pos.below();
|
||||
BlockState farmlandState = world.getBlockState(farmland);
|
||||
if (farmlandState.is(BlockTags.DIRT) || farmlandState.is(Blocks.GRASS_BLOCK)) {
|
||||
BlockState targetBlockstate = world.getBlockState(farmland);
|
||||
if (!(targetBlockstate.getBlock() instanceof FarmBlock) && (targetBlockstate.is(BlockTags.DIRT) || targetBlockstate.is(Blocks.GRASS_BLOCK))) {
|
||||
world.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
|
||||
useHoeAt(world, farmland);
|
||||
world.playSound(null, farmland, SoundEvents.HOE_TILL, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
|
@ -183,7 +180,7 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
|
|||
|
||||
ItemStack itemstack = getHoeStack();
|
||||
|
||||
if (!player.mayUseItemAt(pos.relative(Direction.UP), Direction.UP, itemstack)) {
|
||||
if (!player.mayUseItemAt(pos.relative(Direction.UP), Direction.UP, itemstack)) { //TODO this does nothing. -Flanks
|
||||
return InteractionResult.FAIL;
|
||||
} else {
|
||||
// UseOnContext dummyContext = new UseOnContext(world, player, InteractionHand.MAIN_HAND, itemstack, new BlockHitResult(new Vec3(0.5, 0.5, 0.5), Direction.UP, pos, false));
|
||||
|
|
|
@ -56,6 +56,8 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer
|
|||
|
||||
private int lastEnergy;
|
||||
|
||||
private int area;
|
||||
|
||||
public TileEntityFarmer(BlockPos pos, BlockState state) {
|
||||
super(ActuallyBlocks.FARMER.getTileEntityType(), pos, state, 12);
|
||||
}
|
||||
|
@ -69,6 +71,7 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer
|
|||
compound.putInt("CheckX", this.checkX);
|
||||
compound.putInt("CheckY", this.checkY);
|
||||
}
|
||||
compound.putInt("Area", this.area);
|
||||
this.storage.writeToNBT(compound);
|
||||
super.writeSyncableNBT(compound, lookupProvider, type);
|
||||
}
|
||||
|
@ -82,6 +85,7 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer
|
|||
this.checkX = compound.getInt("CheckX");
|
||||
this.checkY = compound.getInt("CheckY");
|
||||
}
|
||||
this.area = compound.contains("Area") ?compound.getInt("Area"):CommonConfig.Machines.FARMER_AREA.get();
|
||||
this.storage.readFromNBT(compound);
|
||||
super.readSyncableNBT(compound, lookupProvider, type);
|
||||
}
|
||||
|
@ -97,15 +101,15 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer
|
|||
tile.serverTick();
|
||||
|
||||
if (!tile.isRedstonePowered && tile.storage.getEnergyStored() > 0) {
|
||||
int localArea = Math.min(tile.area, CommonConfig.Machines.FARMER_AREA.get());
|
||||
if (tile.waitTime > 0) {
|
||||
tile.waitTime--;
|
||||
|
||||
if (tile.waitTime <= 0) {
|
||||
int area = CommonConfig.Machines.FARMER_AREA.get();
|
||||
if (area % 2 == 0) {
|
||||
area++;
|
||||
if (localArea % 2 == 0) {
|
||||
localArea++;
|
||||
}
|
||||
int radius = area / 2;
|
||||
int radius = localArea / 2;
|
||||
|
||||
BlockPos center = pos.relative(state.getValue(BlockStateProperties.HORIZONTAL_FACING), radius + 1);
|
||||
|
||||
|
@ -194,6 +198,26 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer
|
|||
return this.worldPosition;
|
||||
}
|
||||
|
||||
public int getArea() {
|
||||
return this.area;
|
||||
}
|
||||
|
||||
public void setArea(int area) {
|
||||
this.area = Math.min(area, CommonConfig.Machines.FARMER_AREA.get());
|
||||
}
|
||||
|
||||
public int cycleArea() {
|
||||
if (this.area >= CommonConfig.Machines.FARMER_AREA.get())
|
||||
this.area = 1;
|
||||
else
|
||||
this.area+= 2;
|
||||
|
||||
this.checkY = 0; // Reset the current position so we dont go off the rails and plant behind the machine when spamming area changes.
|
||||
this.checkX = 0;
|
||||
|
||||
return this.area;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return this.worldPosition.getX();
|
||||
|
|
|
@ -507,6 +507,9 @@
|
|||
"info.actuallyadditions.redstoneMode.deactivation": "Deactivation",
|
||||
"info.actuallyadditions.redstoneMode.invalidItem": "Hold a %s to toggle!",
|
||||
"info.actuallyadditions.redstoneMode.validItem": "Right-Click to toggle!",
|
||||
"info.actuallyadditions.farmer.validItem": "Right-Click to change area!",
|
||||
"info.actuallyadditions.farmer.invalidItem": "Hold a %s to modify farming area!",
|
||||
"info.actuallyadditions.farmer.area": "Area: %dx%d",
|
||||
"info.actuallyadditions.laserRelay.item.extra": "Priority",
|
||||
"info.actuallyadditions.laserRelay.item.display.1": "Right-Click to increase!",
|
||||
"info.actuallyadditions.laserRelay.item.display.2": "Sneak-Right-Click to decrease!",
|
||||
|
|
Loading…
Reference in a new issue