Zapper and cannon now place crops in basic growth state

This commit is contained in:
grimmauld 2020-09-05 22:02:07 +02:00
parent 7fea4a66a0
commit 637dee0919
3 changed files with 28 additions and 1 deletions

View file

@ -5,6 +5,7 @@ import java.util.List;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.foundation.item.ItemDescription;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.block.BlockState;
@ -147,6 +148,7 @@ public abstract class ZapperItem extends Item {
BlockState stateToUse = Blocks.AIR.getDefaultState();
if (nbt.contains("BlockUsed"))
stateToUse = NBTUtil.readBlockState(nbt.getCompound("BlockUsed"));
stateToUse = BlockHelper.setZeroAge(stateToUse);
// Raytrace - Find the target
Vec3d start = player.getPositionVec()

View file

@ -23,6 +23,7 @@ import com.simibubi.create.foundation.item.ItemHelper.ExtractionCountMode;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.BlockHelper;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.PistonHeadBlock;
@ -402,7 +403,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
.get(printingEntityIndex));
} else {
blockState = blockReader.getBlockState(target);
blockState = BlockHelper.setZeroAge(blockReader.getBlockState(target));
requirement = ItemRequirement.of(blockState);
shouldSkip = !shouldPlace(target, blockState);
}

View file

@ -64,6 +64,30 @@ public class BlockHelper {
});
}
public static BlockState setZeroAge(BlockState blockState) {
if(blockState.has(BlockStateProperties.AGE_0_1))
return blockState.with(BlockStateProperties.AGE_0_1, 0);
if(blockState.has(BlockStateProperties.AGE_0_2))
return blockState.with(BlockStateProperties.AGE_0_2, 0);
if(blockState.has(BlockStateProperties.AGE_0_3))
return blockState.with(BlockStateProperties.AGE_0_3, 0);
if(blockState.has(BlockStateProperties.AGE_0_5))
return blockState.with(BlockStateProperties.AGE_0_5, 0);
if(blockState.has(BlockStateProperties.AGE_0_7))
return blockState.with(BlockStateProperties.AGE_0_7, 0);
if(blockState.has(BlockStateProperties.AGE_0_15))
return blockState.with(BlockStateProperties.AGE_0_15, 0);
if(blockState.has(BlockStateProperties.AGE_0_25))
return blockState.with(BlockStateProperties.AGE_0_25, 0);
if(blockState.has(BlockStateProperties.HONEY_LEVEL))
return blockState.with(BlockStateProperties.HONEY_LEVEL, 0);
if(blockState.has(BlockStateProperties.HATCH_0_2))
return blockState.with(BlockStateProperties.HATCH_0_2, 0);
if(blockState.has(BlockStateProperties.STAGE_0_1))
return blockState.with(BlockStateProperties.STAGE_0_1, 0);
return blockState;
}
public static int findAndRemoveInInventory(BlockState block, PlayerEntity player, int amount) {
int amountFound = 0;
Item required = getRequiredItem(block).getItem();