mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-13 05:54:17 +01:00
Merge branch 'mc1.16/dev' into pr/2123
This commit is contained in:
commit
d2d3c7f495
@ -10,6 +10,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.simibubi.create.api.behaviour.BlockSpoutingBehaviour;
|
||||
import com.simibubi.create.content.CreateItemGroup;
|
||||
import com.simibubi.create.content.contraptions.TorquePropagator;
|
||||
import com.simibubi.create.content.contraptions.components.flywheel.engine.FurnaceEngineModifiers;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController;
|
||||
import com.simibubi.create.content.curiosities.weapons.BuiltinPotatoProjectileTypes;
|
||||
import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler;
|
||||
@ -98,6 +99,7 @@ public class Create {
|
||||
AllMovementBehaviours.register();
|
||||
AllWorldFeatures.register();
|
||||
AllEnchantments.register();
|
||||
FurnaceEngineModifiers.register();
|
||||
AllConfigs.register(modLoadingContext);
|
||||
BlockSpoutingBehaviour.register();
|
||||
|
||||
|
@ -12,6 +12,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.utility.BlockHelper;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||
@ -23,6 +24,7 @@ import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.CocoaBlock;
|
||||
import net.minecraft.block.CropsBlock;
|
||||
import net.minecraft.block.SugarCaneBlock;
|
||||
import net.minecraft.block.SweetBerryBushBlock;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
@ -50,14 +52,16 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||
|
||||
@Nullable
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
|
||||
ContraptionMatrices matrices, IRenderTypeBuffer buffers) {
|
||||
if (!Backend.getInstance().canUseInstancing())
|
||||
if (!Backend.getInstance()
|
||||
.canUseInstancing())
|
||||
HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers);
|
||||
}
|
||||
|
||||
@ -86,16 +90,18 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||
|
||||
ItemStack item = ItemStack.EMPTY;
|
||||
float effectChance = 1;
|
||||
|
||||
if (stateVisited.getBlock().is(BlockTags.LEAVES)) {
|
||||
|
||||
if (stateVisited.getBlock()
|
||||
.is(BlockTags.LEAVES)) {
|
||||
item = new ItemStack(Items.SHEARS);
|
||||
effectChance = .45f;
|
||||
}
|
||||
|
||||
|
||||
MutableBoolean seedSubtracted = new MutableBoolean(notCropButCuttable);
|
||||
BlockState state = stateVisited;
|
||||
BlockHelper.destroyBlockAs(world, pos, null, item, effectChance, stack -> {
|
||||
if (!seedSubtracted.getValue() && stack.sameItem(new ItemStack(state.getBlock()))) {
|
||||
if (AllConfigs.SERVER.kinetics.harvesterReplants.get() && !seedSubtracted.getValue()
|
||||
&& stack.sameItem(new ItemStack(state.getBlock()))) {
|
||||
stack.shrink(1);
|
||||
seedSubtracted.setTrue();
|
||||
}
|
||||
@ -106,23 +112,31 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||
}
|
||||
|
||||
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) {
|
||||
CropsBlock crop = (CropsBlock) state.getBlock();
|
||||
if (!crop.isMaxAge(state))
|
||||
return false;
|
||||
return true;
|
||||
if (harvestPartial)
|
||||
return state.getValue(crop.getAgeProperty()) != 0 || !replant;
|
||||
return crop.isMaxAge(state);
|
||||
}
|
||||
|
||||
if (state.getCollisionShape(world, pos)
|
||||
.isEmpty() || state.getBlock() instanceof CocoaBlock) {
|
||||
for (Property<?> property : state.getProperties()) {
|
||||
if (!(property instanceof IntegerProperty))
|
||||
continue;
|
||||
IntegerProperty ageProperty = (IntegerProperty) property;
|
||||
if (!property.getName()
|
||||
.equals(BlockStateProperties.AGE_1.getName()))
|
||||
continue;
|
||||
if (((IntegerProperty) property).getPossibleValues()
|
||||
.size() - 1 != state.getValue((IntegerProperty) property)
|
||||
.intValue())
|
||||
int age = state.getValue(ageProperty)
|
||||
.intValue();
|
||||
if (state.getBlock() instanceof SweetBerryBushBlock && age <= 1 && replant)
|
||||
continue;
|
||||
if (age == 0 && replant || !harvestPartial && (ageProperty.getPossibleValues()
|
||||
.size() - 1 != age))
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
@ -136,7 +150,8 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||
return false;
|
||||
if (state.getBlock() instanceof SugarCaneBlock)
|
||||
return true;
|
||||
if (state.getBlock().is(BlockTags.LEAVES))
|
||||
if (state.getBlock()
|
||||
.is(BlockTags.LEAVES))
|
||||
return true;
|
||||
|
||||
if (state.getCollisionShape(world, pos)
|
||||
@ -161,6 +176,14 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||
}
|
||||
|
||||
private BlockState cutCrop(World world, BlockPos pos, BlockState state) {
|
||||
if (!AllConfigs.SERVER.kinetics.harvesterReplants.get()) {
|
||||
if (state.getFluidState()
|
||||
.isEmpty())
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
return state.getFluidState()
|
||||
.createLegacyBlock();
|
||||
}
|
||||
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof CropsBlock) {
|
||||
CropsBlock crop = (CropsBlock) block;
|
||||
@ -171,18 +194,18 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||
}
|
||||
if (block == Blocks.SUGAR_CANE || block instanceof AbstractPlantBlock) {
|
||||
if (state.getFluidState()
|
||||
.isEmpty())
|
||||
.isEmpty())
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
return state.getFluidState()
|
||||
.createLegacyBlock();
|
||||
.createLegacyBlock();
|
||||
}
|
||||
if (state.getCollisionShape(world, pos)
|
||||
.isEmpty() || block instanceof CocoaBlock) {
|
||||
.isEmpty() || block instanceof CocoaBlock) {
|
||||
for (Property<?> property : state.getProperties()) {
|
||||
if (!(property instanceof IntegerProperty))
|
||||
continue;
|
||||
if (!property.getName()
|
||||
.equals(BlockStateProperties.AGE_1.getName()))
|
||||
.equals(BlockStateProperties.AGE_1.getName()))
|
||||
continue;
|
||||
return state.setValue((IntegerProperty) property, Integer.valueOf(0));
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.simibubi.create.content.contraptions.components.flywheel.engine;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
public class FurnaceEngineModifiers {
|
||||
|
||||
public final static FurnaceEngineModifiers INSTANCE = new FurnaceEngineModifiers();
|
||||
|
||||
protected Map<IRegistryDelegate<Block>, Float> blockModifiers = new HashMap<>();
|
||||
|
||||
public void register(IRegistryDelegate<Block> block, float modifier) {
|
||||
this.blockModifiers.put(block, modifier);
|
||||
}
|
||||
|
||||
public float getModifierOrDefault(BlockState state, float defaultValue) {
|
||||
return blockModifiers.getOrDefault(state.getBlock().delegate, defaultValue);
|
||||
}
|
||||
|
||||
public float getModifier(BlockState state) {
|
||||
return getModifierOrDefault(state, 1f);
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
INSTANCE.register(Blocks.BLAST_FURNACE.delegate, 2f);
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@ public class FurnaceEngineTileEntity extends EngineTileEntity {
|
||||
if (!(state.getBlock() instanceof AbstractFurnaceBlock))
|
||||
return;
|
||||
|
||||
float modifier = state.getBlock() == Blocks.BLAST_FURNACE ? 2 : 1;
|
||||
float modifier = FurnaceEngineModifiers.INSTANCE.getModifier(state);
|
||||
boolean active = state.hasProperty(AbstractFurnaceBlock.LIT) && state.getValue(AbstractFurnaceBlock.LIT);
|
||||
float speed = active ? 16 * modifier : 0;
|
||||
float capacity =
|
||||
|
@ -5,6 +5,7 @@ import javax.annotation.Nullable;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
@ -33,7 +34,11 @@ public abstract class MovementBehaviour {
|
||||
}
|
||||
|
||||
public void dropItem(MovementContext context, ItemStack stack) {
|
||||
ItemStack remainder = ItemHandlerHelper.insertItem(context.contraption.inventory, stack, false);
|
||||
ItemStack remainder;
|
||||
if (AllConfigs.SERVER.kinetics.moveItemsToStorage.get())
|
||||
remainder = ItemHandlerHelper.insertItem(context.contraption.inventory, stack, false);
|
||||
else
|
||||
remainder = stack;
|
||||
if (remainder.isEmpty())
|
||||
return;
|
||||
|
||||
|
@ -29,14 +29,14 @@ public abstract class FluidTransportBehaviour extends TileEntityBehaviour {
|
||||
|
||||
public static BehaviourType<FluidTransportBehaviour> TYPE = new BehaviourType<>();
|
||||
|
||||
enum UpdatePhase {
|
||||
public enum UpdatePhase {
|
||||
WAIT_FOR_PUMPS, // Do not run Layer II logic while pumps could still be distributing pressure
|
||||
FLIP_FLOWS, // Do not cut any flows until all pipes had a chance to reverse them
|
||||
IDLE; // Operate normally
|
||||
}
|
||||
|
||||
Map<Direction, PipeConnection> interfaces;
|
||||
UpdatePhase phase;
|
||||
public Map<Direction, PipeConnection> interfaces;
|
||||
public UpdatePhase phase;
|
||||
|
||||
public FluidTransportBehaviour(SmartTileEntity te) {
|
||||
super(te);
|
||||
|
@ -11,6 +11,7 @@ import javax.annotation.Nullable;
|
||||
import com.simibubi.create.AllFluids;
|
||||
import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler;
|
||||
import com.simibubi.create.foundation.advancement.AllTriggers;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.fluid.FluidHelper;
|
||||
import com.simibubi.create.foundation.utility.BlockFace;
|
||||
|
||||
@ -214,6 +215,10 @@ public class OpenEndedPipe extends FlowSource {
|
||||
.scheduleTick(outputPos, Fluids.WATER, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!AllConfigs.SERVER.fluids.placeFluidSourceBlocks.get())
|
||||
return true;
|
||||
|
||||
world.setBlock(outputPos, fluid.getFluid()
|
||||
.defaultFluidState()
|
||||
.createLegacyBlock(), 3);
|
||||
|
@ -32,7 +32,7 @@ import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
public class PipeConnection {
|
||||
|
||||
Direction side;
|
||||
public Direction side;
|
||||
|
||||
// Layer I
|
||||
Couple<Float> pressure; // [inbound, outward]
|
||||
|
@ -7,6 +7,7 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import com.simibubi.create.foundation.advancement.AllTriggers;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.fluid.FluidHelper;
|
||||
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType;
|
||||
@ -126,23 +127,25 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour {
|
||||
int maxBlocks = maxBlocks();
|
||||
boolean evaporate = world.dimensionType()
|
||||
.ultraWarm() && fluid.is(FluidTags.WATER);
|
||||
boolean canPlaceSources = AllConfigs.SERVER.fluids.placeFluidSourceBlocks.get();
|
||||
|
||||
if ((!fillInfinite() && infinite) || evaporate) {
|
||||
if ((!fillInfinite() && infinite) || evaporate || !canPlaceSources) {
|
||||
FluidState fluidState = world.getFluidState(rootPos);
|
||||
boolean equivalentTo = fluidState.getType()
|
||||
.isSame(fluid);
|
||||
if (!equivalentTo && !evaporate)
|
||||
if (!equivalentTo && !evaporate && canPlaceSources)
|
||||
return false;
|
||||
if (simulate)
|
||||
return true;
|
||||
playEffect(world, null, fluid, false);
|
||||
playEffect(world, root, fluid, false);
|
||||
if (evaporate) {
|
||||
int i = root.getX();
|
||||
int j = root.getY();
|
||||
int k = root.getZ();
|
||||
world.playSound(null, i, j, k, SoundEvents.FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F,
|
||||
2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
|
||||
}
|
||||
} else if (!canPlaceSources)
|
||||
AllTriggers.triggerForNearbyPlayers(AllTriggers.HOSE_PULLEY, world, tileEntity.getBlockPos(), 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,8 @@ public class CFluids extends ConfigBase {
|
||||
public final ConfigBool fillInfinite = b(false, "fillInfinite", Comments.fillInfinite);
|
||||
public final ConfigInt hosePulleyRange = i(128, 1, "hosePulleyRange", Comments.blocks, Comments.hosePulleyRange);
|
||||
|
||||
public ConfigBool placeFluidSourceBlocks = b(true, "placeFluidSourceBlocks", Comments.placeFluidSourceBlocks);
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "fluids";
|
||||
@ -30,6 +32,7 @@ public class CFluids extends ConfigBase {
|
||||
static String hosePulleyBlockThreshold =
|
||||
"The minimum amount of fluid blocks the hose pulley needs to find before deeming it an infinite source.";
|
||||
static String fillInfinite = "Whether hose pulleys should continue filling up above-threshold sources";
|
||||
static String placeFluidSourceBlocks = "Whether open-ended pipes and hose pulleys should be allowed to place fluid sources";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,6 +40,9 @@ public class CKinetics extends ConfigBase {
|
||||
e(ContraptionMovementSetting.NO_PICKUP, "movableSpawners", Comments.spawnerMovement);
|
||||
public final ConfigEnum<ContraptionMovementSetting> obsidianMovement =
|
||||
e(ContraptionMovementSetting.UNMOVABLE, "movableObsidian", Comments.obsidianMovement);
|
||||
public ConfigBool moveItemsToStorage = b(true, "moveItemsToStorage", Comments.moveItemsToStorage);
|
||||
public ConfigBool harvestPartiallyGrown = b(false, "harvestPartiallyGrown", Comments.harvestPartiallyGrown);
|
||||
public ConfigBool harvesterReplants = b(true, "harvesterReplants", Comments.harvesterReplants);
|
||||
|
||||
public final CStress stressValues = nested(1, CStress::new, Comments.stress);
|
||||
|
||||
@ -76,6 +79,10 @@ public class CKinetics extends ConfigBase {
|
||||
static String maxPistonPoles = "Maximum amount of extension poles behind a Mechanical Piston.";
|
||||
static String maxRopeLength = "Max length of rope available off a Rope Pulley.";
|
||||
static String maxCartCouplingLength = "Maximum allowed distance of two coupled minecarts.";
|
||||
static String moveItemsToStorage =
|
||||
"Whether items mined or harvested by contraptions should be placed in their mounted storage.";
|
||||
static String harvestPartiallyGrown = "Whether harvesters should break crops that aren't fully grown.";
|
||||
static String harvesterReplants = "Whether harvesters should replant crops after harvesting.";
|
||||
static String stats = "Configure speed/capacity levels for requirements and indicators.";
|
||||
static String rpm = "[in Revolutions per Minute]";
|
||||
static String su = "[in Stress Units]";
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.simibubi.create.foundation.utility.worldWrappers;
|
||||
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.chunk.ChunkStatus;
|
||||
import net.minecraft.world.chunk.listener.IChunkStatusListener;
|
||||
|
||||
public class DummyStatusListener implements IChunkStatusListener {
|
||||
|
||||
@Override
|
||||
public void updateSpawnPos(ChunkPos p_219509_1_) {}
|
||||
|
||||
@Override
|
||||
public void onStatusChange(ChunkPos p_219508_1_, ChunkStatus p_219508_2_) {}
|
||||
|
||||
@Override
|
||||
public void stop() {}
|
||||
|
||||
}
|
@ -37,8 +37,10 @@ public class WrappedServerWorld extends ServerWorld {
|
||||
protected World world;
|
||||
|
||||
public WrappedServerWorld(World world) {
|
||||
// Replace null with world.getChunkProvider().chunkManager.progressListener ? We had null in 1.15
|
||||
super(world.getServer(), Util.backgroundExecutor(), getLevelSaveFromWorld(world), (IServerWorldInfo) world.getLevelData(), world.dimension(), world.dimensionType(), null, ((ServerChunkProvider) world.getChunkSource()).getGenerator(), world.isDebug(), world.getBiomeManager().biomeZoomSeed, Collections.EMPTY_LIST, false); //, world.field_25143);
|
||||
super(world.getServer(), Util.backgroundExecutor(), getLevelSaveFromWorld(world),
|
||||
(IServerWorldInfo) world.getLevelData(), world.dimension(), world.dimensionType(),
|
||||
new DummyStatusListener(), ((ServerChunkProvider) world.getChunkSource()).getGenerator(), world.isDebug(),
|
||||
world.getBiomeManager().biomeZoomSeed, Collections.emptyList(), false);
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user