mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-30 17:06:56 +01:00
commit
616a515939
8 changed files with 143 additions and 22 deletions
|
@ -119,7 +119,7 @@ public abstract class Contraption {
|
||||||
|
|
||||||
public Optional<List<AxisAlignedBB>> simplifiedEntityColliders;
|
public Optional<List<AxisAlignedBB>> simplifiedEntityColliders;
|
||||||
public AbstractContraptionEntity entity;
|
public AbstractContraptionEntity entity;
|
||||||
public CombinedInvWrapper inventory;
|
public ContraptionInvWrapper inventory;
|
||||||
public CombinedTankWrapper fluidInventory;
|
public CombinedTankWrapper fluidInventory;
|
||||||
public AxisAlignedBB bounds;
|
public AxisAlignedBB bounds;
|
||||||
public BlockPos anchor;
|
public BlockPos anchor;
|
||||||
|
@ -252,7 +252,7 @@ public abstract class Contraption {
|
||||||
.stream()
|
.stream()
|
||||||
.map(MountedStorage::getItemHandler)
|
.map(MountedStorage::getItemHandler)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
inventory = new CombinedInvWrapper(Arrays.copyOf(list.toArray(), list.size(), IItemHandlerModifiable[].class));
|
inventory = new ContraptionInvWrapper(Arrays.copyOf(list.toArray(), list.size(), IItemHandlerModifiable[].class));
|
||||||
|
|
||||||
List<IFluidHandler> fluidHandlers = fluidStorage.values()
|
List<IFluidHandler> fluidHandlers = fluidStorage.values()
|
||||||
.stream()
|
.stream()
|
||||||
|
@ -739,7 +739,7 @@ public abstract class Contraption {
|
||||||
for (MountedFluidStorage mountedStorage : fluidStorage.values())
|
for (MountedFluidStorage mountedStorage : fluidStorage.values())
|
||||||
fluidHandlers[index++] = mountedStorage.getFluidHandler();
|
fluidHandlers[index++] = mountedStorage.getFluidHandler();
|
||||||
|
|
||||||
inventory = new CombinedInvWrapper(handlers);
|
inventory = new ContraptionInvWrapper(handlers);
|
||||||
fluidInventory = new CombinedTankWrapper(fluidHandlers);
|
fluidInventory = new CombinedTankWrapper(fluidHandlers);
|
||||||
|
|
||||||
if (nbt.contains("BoundsFront"))
|
if (nbt.contains("BoundsFront"))
|
||||||
|
@ -1053,8 +1053,10 @@ public abstract class Contraption {
|
||||||
BlockFlags.IS_MOVING | BlockFlags.DEFAULT, 512);
|
BlockFlags.IS_MOVING | BlockFlags.DEFAULT, 512);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < inventory.getSlots(); i++)
|
for (int i = 0; i < inventory.getSlots(); i++) {
|
||||||
inventory.setStackInSlot(i, ItemStack.EMPTY);
|
if (!inventory.isSlotExternal(i))
|
||||||
|
inventory.setStackInSlot(i, ItemStack.EMPTY);
|
||||||
|
}
|
||||||
for (int i = 0; i < fluidInventory.getTanks(); i++)
|
for (int i = 0; i < fluidInventory.getTanks(); i++)
|
||||||
fluidInventory.drain(fluidInventory.getFluidInTank(i), FluidAction.EXECUTE);
|
fluidInventory.drain(fluidInventory.getFluidInTank(i), FluidAction.EXECUTE);
|
||||||
|
|
||||||
|
@ -1261,4 +1263,24 @@ public abstract class Contraption {
|
||||||
return pos.equals(te.getPos());
|
return pos.equals(te.getPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class ContraptionInvWrapper extends CombinedInvWrapper {
|
||||||
|
protected final boolean isExternal;
|
||||||
|
|
||||||
|
public ContraptionInvWrapper(boolean isExternal, IItemHandlerModifiable... itemHandler) {
|
||||||
|
super(itemHandler);
|
||||||
|
this.isExternal = isExternal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContraptionInvWrapper(IItemHandlerModifiable... itemHandler) {
|
||||||
|
this(false, itemHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSlotExternal(int slot) {
|
||||||
|
if (isExternal)
|
||||||
|
return true;
|
||||||
|
IItemHandlerModifiable handler = getHandlerFromIndex(getIndexForSlot(slot));
|
||||||
|
return handler instanceof ContraptionInvWrapper && ((ContraptionInvWrapper) handler).isSlotExternal(slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
|
||||||
protected Axis rotationAxis;
|
protected Axis rotationAxis;
|
||||||
protected float prevAngle;
|
protected float prevAngle;
|
||||||
protected float angle;
|
protected float angle;
|
||||||
|
protected float angleDelta;
|
||||||
|
|
||||||
public ControlledContraptionEntity(EntityType<?> type, World world) {
|
public ControlledContraptionEntity(EntityType<?> type, World world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
|
@ -130,6 +131,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
|
||||||
public void setPositionAndRotationDirect(double x, double y, double z, float yw, float pt, int inc, boolean t) {}
|
public void setPositionAndRotationDirect(double x, double y, double z, float yw, float pt, int inc, boolean t) {}
|
||||||
|
|
||||||
protected void tickContraption() {
|
protected void tickContraption() {
|
||||||
|
angleDelta = angle - prevAngle;
|
||||||
prevAngle = angle;
|
prevAngle = angle;
|
||||||
tickActors();
|
tickActors();
|
||||||
|
|
||||||
|
@ -171,7 +173,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
|
||||||
return false;
|
return false;
|
||||||
if (!VecHelper.onSameAxis(blockInfo.pos, BlockPos.ZERO, facing.getAxis()))
|
if (!VecHelper.onSameAxis(blockInfo.pos, BlockPos.ZERO, facing.getAxis()))
|
||||||
return false;
|
return false;
|
||||||
context.motion = Vector3d.of(facing.getDirectionVec()).scale(angle - prevAngle);
|
context.motion = Vector3d.of(facing.getDirectionVec()).scale(angleDelta / 360.0);
|
||||||
context.relativeMotion = context.motion;
|
context.relativeMotion = context.motion;
|
||||||
int timer = context.data.getInt("StationaryTimer");
|
int timer = context.data.getInt("StationaryTimer");
|
||||||
if (timer > 0) {
|
if (timer > 0) {
|
||||||
|
|
|
@ -159,8 +159,8 @@ public class MountedContraption extends Contraption {
|
||||||
public void addExtraInventories(Entity cart) {
|
public void addExtraInventories(Entity cart) {
|
||||||
if (!(cart instanceof IInventory))
|
if (!(cart instanceof IInventory))
|
||||||
return;
|
return;
|
||||||
IItemHandlerModifiable handlerFromInv = new InvWrapper((IInventory) cart);
|
IItemHandlerModifiable handlerFromInv = new ContraptionInvWrapper(true, new InvWrapper((IInventory) cart));
|
||||||
inventory = new CombinedInvWrapper(handlerFromInv, inventory);
|
inventory = new ContraptionInvWrapper(handlerFromInv, inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,6 +4,8 @@ import com.simibubi.create.AllItems;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController;
|
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController;
|
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.utility.Iterate;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
@ -78,6 +80,11 @@ public class MinecartCouplingItem extends Item {
|
||||||
if (event.getWorld().isRemote)
|
if (event.getWorld().isRemote)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
for (boolean forward : Iterate.trueAndFalse) {
|
||||||
|
if (controller.hasContraptionCoupling(forward))
|
||||||
|
couplings--;
|
||||||
|
}
|
||||||
|
|
||||||
CouplingHandler.status(player, "removed");
|
CouplingHandler.status(player, "removed");
|
||||||
controller.decouple();
|
controller.decouple();
|
||||||
if (!player.isCreative())
|
if (!player.isCreative())
|
||||||
|
|
|
@ -202,6 +202,9 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyBlockUpdate(BlockPos pos, BlockState oldState, BlockState newState, int flags) { }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITickList<Block> getPendingBlockTicks() {
|
public ITickList<Block> getPendingBlockTicks() {
|
||||||
return EmptyTickList.get();
|
return EmptyTickList.get();
|
||||||
|
@ -233,4 +236,5 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld {
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("Cannot use IServerWorld#getWorld in a client environment");
|
throw new IllegalStateException("Cannot use IServerWorld#getWorld in a client environment");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.utility.worldWrappers.chunk.EmptierChunk;
|
||||||
import com.simibubi.create.foundation.utility.worldWrappers.chunk.WrappedChunk;
|
import com.simibubi.create.foundation.utility.worldWrappers.chunk.WrappedChunk;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -52,11 +53,11 @@ public class WrappedChunkProvider extends AbstractChunkProvider {
|
||||||
return getChunk(x, z);
|
return getChunk(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WrappedChunk getChunk(int x, int z) {
|
public IChunk getChunk(int x, int z) {
|
||||||
long pos = ChunkPos.asLong(x, z);
|
long pos = ChunkPos.asLong(x, z);
|
||||||
|
|
||||||
if (chunks == null)
|
if (chunks == null)
|
||||||
return null;
|
return new EmptierChunk();
|
||||||
|
|
||||||
return chunks.computeIfAbsent(pos, $ -> new WrappedChunk(world, x, z));
|
return chunks.computeIfAbsent(pos, $ -> new WrappedChunk(world, x, z));
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,14 @@ import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.SoundCategory;
|
import net.minecraft.util.SoundCategory;
|
||||||
import net.minecraft.util.SoundEvent;
|
import net.minecraft.util.SoundEvent;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.SectionPos;
|
||||||
import net.minecraft.util.registry.DynamicRegistries;
|
import net.minecraft.util.registry.DynamicRegistries;
|
||||||
import net.minecraft.world.ITickList;
|
import net.minecraft.world.ITickList;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.chunk.AbstractChunkProvider;
|
import net.minecraft.world.chunk.AbstractChunkProvider;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
import net.minecraft.world.chunk.ChunkSection;
|
||||||
import net.minecraft.world.lighting.WorldLightManager;
|
import net.minecraft.world.lighting.WorldLightManager;
|
||||||
import net.minecraft.world.storage.ISpawnWorldInfo;
|
import net.minecraft.world.storage.ISpawnWorldInfo;
|
||||||
import net.minecraft.world.storage.MapData;
|
import net.minecraft.world.storage.MapData;
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
package com.simibubi.create.foundation.utility.worldWrappers.chunk;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.fluid.FluidState;
|
||||||
|
import net.minecraft.fluid.Fluids;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
import net.minecraft.world.lighting.WorldLightManager;
|
||||||
|
import net.minecraft.world.server.ChunkHolder;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
public class EmptierChunk extends Chunk {
|
||||||
|
|
||||||
|
public EmptierChunk() {
|
||||||
|
super(null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getBlockState(BlockPos p_180495_1_) {
|
||||||
|
return Blocks.VOID_AIR.getDefaultState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public BlockState setBlockState(BlockPos p_177436_1_, BlockState p_177436_2_, boolean p_177436_3_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FluidState getFluidState(BlockPos p_204610_1_) {
|
||||||
|
return Fluids.EMPTY.getDefaultState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public WorldLightManager getWorldLightManager() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLightValue(BlockPos p_217298_1_) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEntity(Entity p_76612_1_) { }
|
||||||
|
|
||||||
|
public void removeEntity(Entity p_76622_1_) { }
|
||||||
|
|
||||||
|
public void removeEntityAtIndex(Entity p_76608_1_, int p_76608_2_) { }
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public TileEntity getTileEntity(BlockPos p_177424_1_, Chunk.CreateEntityType p_177424_2_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTileEntity(TileEntity p_150813_1_) { }
|
||||||
|
|
||||||
|
public void addTileEntity(BlockPos p_177426_1_, TileEntity p_177426_2_) { }
|
||||||
|
|
||||||
|
public void removeTileEntity(BlockPos p_177425_1_) { }
|
||||||
|
|
||||||
|
public void markDirty() { }
|
||||||
|
|
||||||
|
public void getEntitiesWithinAABBForEntity(@Nullable Entity p_177414_1_, AxisAlignedBB p_177414_2_, List<Entity> p_177414_3_, Predicate<? super Entity> p_177414_4_) { }
|
||||||
|
|
||||||
|
public <T extends Entity> void getEntitiesOfTypeWithinAABB(Class<? extends T> p_177430_1_, AxisAlignedBB p_177430_2_, List<T> p_177430_3_, Predicate<? super T> p_177430_4_) { }
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmptyBetween(int p_76606_1_, int p_76606_2_) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChunkHolder.LocationType getLocationType() {
|
||||||
|
return ChunkHolder.LocationType.BORDER;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue