mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-29 08:27:03 +01:00
Update HarvesterMovementBehaviour.java
- harvestpartial only breaks age zero crops if replant is disabled
This commit is contained in:
parent
a2043bebc5
commit
3093bf5917
1 changed files with 33 additions and 22 deletions
|
@ -24,6 +24,7 @@ import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.CocoaBlock;
|
import net.minecraft.block.CocoaBlock;
|
||||||
import net.minecraft.block.CropsBlock;
|
import net.minecraft.block.CropsBlock;
|
||||||
import net.minecraft.block.SugarCaneBlock;
|
import net.minecraft.block.SugarCaneBlock;
|
||||||
|
import net.minecraft.block.SweetBerryBushBlock;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
|
@ -51,14 +52,16 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ActorInstance createInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
public ActorInstance createInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld,
|
||||||
|
MovementContext context) {
|
||||||
return new HarvesterActorInstance(materialManager, simulationWorld, context);
|
return new HarvesterActorInstance(materialManager, simulationWorld, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
|
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
|
||||||
ContraptionMatrices matrices, IRenderTypeBuffer buffers) {
|
ContraptionMatrices matrices, IRenderTypeBuffer buffers) {
|
||||||
if (!Backend.getInstance().canUseInstancing())
|
if (!Backend.getInstance()
|
||||||
|
.canUseInstancing())
|
||||||
HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers);
|
HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +91,8 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||||
ItemStack item = ItemStack.EMPTY;
|
ItemStack item = ItemStack.EMPTY;
|
||||||
float effectChance = 1;
|
float effectChance = 1;
|
||||||
|
|
||||||
if (stateVisited.getBlock().is(BlockTags.LEAVES)) {
|
if (stateVisited.getBlock()
|
||||||
|
.is(BlockTags.LEAVES)) {
|
||||||
item = new ItemStack(Items.SHEARS);
|
item = new ItemStack(Items.SHEARS);
|
||||||
effectChance = .45f;
|
effectChance = .45f;
|
||||||
}
|
}
|
||||||
|
@ -96,8 +100,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||||
MutableBoolean seedSubtracted = new MutableBoolean(notCropButCuttable);
|
MutableBoolean seedSubtracted = new MutableBoolean(notCropButCuttable);
|
||||||
BlockState state = stateVisited;
|
BlockState state = stateVisited;
|
||||||
BlockHelper.destroyBlockAs(world, pos, null, item, effectChance, stack -> {
|
BlockHelper.destroyBlockAs(world, pos, null, item, effectChance, stack -> {
|
||||||
if (AllConfigs.SERVER.kinetics.harvesterReplants.get()
|
if (AllConfigs.SERVER.kinetics.harvesterReplants.get() && !seedSubtracted.getValue()
|
||||||
&& !seedSubtracted.getValue()
|
|
||||||
&& stack.sameItem(new ItemStack(state.getBlock()))) {
|
&& stack.sameItem(new ItemStack(state.getBlock()))) {
|
||||||
stack.shrink(1);
|
stack.shrink(1);
|
||||||
seedSubtracted.setTrue();
|
seedSubtracted.setTrue();
|
||||||
|
@ -109,24 +112,31 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isValidCrop(World world, BlockPos pos, BlockState state) {
|
private boolean isValidCrop(World world, BlockPos pos, BlockState state) {
|
||||||
|
boolean harvestPartial = AllConfigs.SERVER.kinetics.harvestPartiallyGrown.get();
|
||||||
|
boolean replant = AllConfigs.SERVER.kinetics.harvesterReplants.get();
|
||||||
|
|
||||||
if (state.getBlock() instanceof CropsBlock) {
|
if (state.getBlock() instanceof CropsBlock) {
|
||||||
CropsBlock crop = (CropsBlock) state.getBlock();
|
CropsBlock crop = (CropsBlock) state.getBlock();
|
||||||
if (!crop.isMaxAge(state) && !AllConfigs.SERVER.kinetics.harvestPartiallyGrown.get())
|
if (harvestPartial)
|
||||||
return false;
|
return state.getValue(crop.getAgeProperty()) != 0 || !replant;
|
||||||
return true;
|
return crop.isMaxAge(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.getCollisionShape(world, pos)
|
if (state.getCollisionShape(world, pos)
|
||||||
.isEmpty() || state.getBlock() instanceof CocoaBlock) {
|
.isEmpty() || state.getBlock() instanceof CocoaBlock) {
|
||||||
for (Property<?> property : state.getProperties()) {
|
for (Property<?> property : state.getProperties()) {
|
||||||
if (!(property instanceof IntegerProperty))
|
if (!(property instanceof IntegerProperty))
|
||||||
continue;
|
continue;
|
||||||
|
IntegerProperty ageProperty = (IntegerProperty) property;
|
||||||
if (!property.getName()
|
if (!property.getName()
|
||||||
.equals(BlockStateProperties.AGE_1.getName()))
|
.equals(BlockStateProperties.AGE_1.getName()))
|
||||||
continue;
|
continue;
|
||||||
if (!AllConfigs.SERVER.kinetics.harvestPartiallyGrown.get()
|
int age = state.getValue(ageProperty)
|
||||||
&& (((IntegerProperty) property).getPossibleValues().size() - 1
|
.intValue();
|
||||||
!= state.getValue((IntegerProperty) property)
|
if (state.getBlock() instanceof SweetBerryBushBlock && age <= 1 && replant)
|
||||||
.intValue()))
|
continue;
|
||||||
|
if (age == 0 && replant || !harvestPartial && (ageProperty.getPossibleValues()
|
||||||
|
.size() - 1 != age))
|
||||||
continue;
|
continue;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +150,8 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||||
return false;
|
return false;
|
||||||
if (state.getBlock() instanceof SugarCaneBlock)
|
if (state.getBlock() instanceof SugarCaneBlock)
|
||||||
return true;
|
return true;
|
||||||
if (state.getBlock().is(BlockTags.LEAVES))
|
if (state.getBlock()
|
||||||
|
.is(BlockTags.LEAVES))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (state.getCollisionShape(world, pos)
|
if (state.getCollisionShape(world, pos)
|
||||||
|
|
Loading…
Reference in a new issue