mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-14 12:03:49 +01:00
Merge remote-tracking branch 'upstream/mc1.15/dev' into mc1.15/dev
This commit is contained in:
commit
cef93ab0a8
14 changed files with 86 additions and 19 deletions
|
@ -8,6 +8,8 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
|||
import com.simibubi.create.content.contraptions.components.crafter.ConnectedInputHandler.ConnectedInput;
|
||||
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity.Phase;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.Pointing;
|
||||
|
@ -234,6 +236,14 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT
|
|||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
InvManipulationBehaviour behaviour = TileEntityBehaviour.get(worldIn, pos, InvManipulationBehaviour.TYPE);
|
||||
if (behaviour != null)
|
||||
behaviour.onNeighborChanged(fromPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getParticleTargetRadius() {
|
||||
return .85f;
|
||||
|
|
|
@ -3,6 +3,9 @@ package com.simibubi.create.content.contraptions.components.structureMovement.be
|
|||
import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -29,4 +32,15 @@ public abstract class BearingBlock extends DirectionalKineticBlock {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
|
||||
ActionResultType resultType = super.onWrenched(state, context);
|
||||
if (!context.getWorld().isRemote && resultType.isAccepted()) {
|
||||
TileEntity te = context.getWorld().getTileEntity(context.getPos());
|
||||
if (te instanceof MechanicalBearingTileEntity) {
|
||||
((MechanicalBearingTileEntity) te).disassemble();
|
||||
}
|
||||
}
|
||||
return resultType;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.simibubi.create.foundation.block.ITE;
|
|||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
|
@ -51,4 +52,12 @@ public class ClockworkBearingBlock extends BearingBlock implements ITE<Clockwork
|
|||
return ClockworkBearingTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
|
||||
ActionResultType resultType = super.onWrenched(state, context);
|
||||
if (!context.getWorld().isRemote && resultType.isAccepted())
|
||||
withTileEntityDo(context.getWorld(), context.getPos(), ClockworkBearingTileEntity::disassemble);
|
||||
return resultType;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.simibubi.create.content.logistics.block.belts.tunnel;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.content.logistics.packet.TunnelFlapPacket;
|
||||
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
|
||||
import com.simibubi.create.foundation.networking.AllPackets;
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.world.IWorld;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
|
||||
public abstract class AbstractChuteBlock extends Block implements IWrenchable, ITE<ChuteTileEntity> {
|
||||
|
||||
|
@ -156,9 +157,10 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I
|
|||
@Override
|
||||
public void neighborChanged(BlockState p_220069_1_, World world, BlockPos pos, Block p_220069_4_,
|
||||
BlockPos neighbourPos, boolean p_220069_6_) {
|
||||
if (pos.down()
|
||||
.equals(neighbourPos))
|
||||
if (pos.down().equals(neighbourPos))
|
||||
withTileEntityDo(world, pos, ChuteTileEntity::blockBelowChanged);
|
||||
else if (pos.up().equals(neighbourPos))
|
||||
withTileEntityDo(world, pos, chute -> chute.capAbove = LazyOptional.empty());
|
||||
}
|
||||
|
||||
public abstract BlockState updateChuteState(BlockState state, BlockState above, IBlockReader world, BlockPos pos);
|
||||
|
|
|
@ -272,6 +272,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
|||
|
||||
public void blockBelowChanged() {
|
||||
updateAirFlow = true;
|
||||
capBelow = LazyOptional.empty();
|
||||
}
|
||||
|
||||
private void spawnParticles(float itemMotion) {
|
||||
|
|
|
@ -59,6 +59,9 @@ public abstract class AbstractFunnelBlock extends Block implements ITE<FunnelTil
|
|||
boolean isMoving) {
|
||||
if (worldIn.isRemote)
|
||||
return;
|
||||
InvManipulationBehaviour behaviour = TileEntityBehaviour.get(worldIn, pos, InvManipulationBehaviour.TYPE);
|
||||
if (behaviour != null)
|
||||
behaviour.onNeighborChanged(fromPos);
|
||||
boolean previouslyPowered = state.get(POWERED);
|
||||
if (previouslyPowered != worldIn.isBlockPowered(pos))
|
||||
worldIn.setBlockState(pos, state.cycle(POWERED), 2);
|
||||
|
|
|
@ -111,7 +111,7 @@ public class AdjustableCrateBlock extends CrateBlock {
|
|||
public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) {
|
||||
TileEntity te = worldIn.getTileEntity(pos);
|
||||
if (te instanceof AdjustableCrateTileEntity) {
|
||||
AdjustableCrateTileEntity flexcrateTileEntity = (AdjustableCrateTileEntity) te;
|
||||
AdjustableCrateTileEntity flexcrateTileEntity = ((AdjustableCrateTileEntity) te).getMainCrate();
|
||||
return ItemHelper.calcRedstoneFromInventory(flexcrateTileEntity.inventory);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.simibubi.create.foundation.block.ITE;
|
|||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -129,6 +130,14 @@ public class ContentObserverBlock extends HorizontalBlock implements ITE<Content
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
InvManipulationBehaviour behaviour = TileEntityBehaviour.get(worldIn, pos, InvManipulationBehaviour.TYPE);
|
||||
if (behaviour != null)
|
||||
behaviour.onNeighborChanged(fromPos);
|
||||
}
|
||||
|
||||
public void onFunnelTransfer(World world, BlockPos funnelPos, ItemStack transferred) {
|
||||
for (Direction direction : Iterate.horizontalDirections) {
|
||||
BlockPos detectorPos = funnelPos.offset(direction);
|
||||
|
|
|
@ -62,6 +62,7 @@ public class StockpileSwitchTileEntity extends SmartTileEntity {
|
|||
|
||||
public void updateCurrentLevel() {
|
||||
boolean changed = false;
|
||||
observedInventory.findNewCapability();
|
||||
if (!observedInventory.hasInventory()) {
|
||||
if (currentLevel == -1)
|
||||
return;
|
||||
|
|
|
@ -71,4 +71,10 @@ public class SchematicannonBlock extends Block implements ITE<SchematicannonTile
|
|||
return SchematicannonTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
withTileEntityDo(worldIn, pos, te -> te.neighbourCheckCooldown = 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.simibubi.create.content.schematics.block;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -9,7 +10,6 @@ import com.simibubi.create.AllBlocks;
|
|||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.AllSoundEvents;
|
||||
import com.simibubi.create.AllTags.AllBlockTags;
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.content.contraptions.relays.belt.BeltBlock;
|
||||
import com.simibubi.create.content.contraptions.relays.belt.BeltPart;
|
||||
import com.simibubi.create.content.contraptions.relays.belt.BeltSlope;
|
||||
|
@ -65,10 +65,10 @@ import net.minecraft.world.gen.feature.template.Template;
|
|||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import net.minecraftforge.items.wrapper.EmptyHandler;
|
||||
|
||||
public class SchematicannonTileEntity extends SmartTileEntity implements INamedContainerProvider, IInstanceRendered {
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
|
|||
|
||||
public BlockPos target;
|
||||
public BlockPos previousTarget;
|
||||
public List<IItemHandler> attachedInventories;
|
||||
public LinkedHashSet<LazyOptional<IItemHandler>> attachedInventories;
|
||||
public List<LaunchedItem> flyingBlocks;
|
||||
public MaterialChecklist checklist;
|
||||
|
||||
|
@ -137,14 +137,13 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
|
|||
public SchematicannonTileEntity(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
setLazyTickRate(30);
|
||||
attachedInventories = new LinkedList<>();
|
||||
attachedInventories = new LinkedHashSet<>();
|
||||
flyingBlocks = new LinkedList<>();
|
||||
inventory = new SchematicannonInventory(this);
|
||||
statusMsg = "idle";
|
||||
state = State.STOPPED;
|
||||
printingEntityIndex = -1;
|
||||
replaceMode = 2;
|
||||
neighbourCheckCooldown = NEIGHBOUR_CHECKING;
|
||||
checklist = new MaterialChecklist();
|
||||
}
|
||||
|
||||
|
@ -164,7 +163,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
|
|||
LazyOptional<IItemHandler> capability =
|
||||
tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite());
|
||||
if (capability.isPresent()) {
|
||||
attachedInventories.add(capability.orElse(null));
|
||||
attachedInventories.add(capability);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -288,7 +287,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
|
|||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
if (neighbourCheckCooldown-- <= 0) {
|
||||
if (state != State.STOPPED && neighbourCheckCooldown-- <= 0) {
|
||||
neighbourCheckCooldown = NEIGHBOUR_CHECKING;
|
||||
findInventories();
|
||||
}
|
||||
|
@ -577,9 +576,12 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
|
|||
if (hasCreativeCrate)
|
||||
return true;
|
||||
|
||||
attachedInventories.removeIf(cap -> !cap.isPresent());
|
||||
|
||||
// Find and apply damage
|
||||
if (usage == ItemUseType.DAMAGE) {
|
||||
for (IItemHandler iItemHandler : attachedInventories) {
|
||||
for (LazyOptional<IItemHandler> cap : attachedInventories) {
|
||||
IItemHandler iItemHandler = cap.orElse(EmptyHandler.INSTANCE);
|
||||
for (int slot = 0; slot < iItemHandler.getSlots(); slot++) {
|
||||
ItemStack extractItem = iItemHandler.extractItem(slot, 1, true);
|
||||
if (!ItemRequirement.validate(required, extractItem))
|
||||
|
@ -608,8 +610,8 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
|
|||
boolean success = false;
|
||||
if (usage == ItemUseType.CONSUME) {
|
||||
int amountFound = 0;
|
||||
for (IItemHandler iItemHandler : attachedInventories) {
|
||||
|
||||
for (LazyOptional<IItemHandler> cap : attachedInventories) {
|
||||
IItemHandler iItemHandler = cap.orElse(EmptyHandler.INSTANCE);
|
||||
amountFound += ItemHelper
|
||||
.extract(iItemHandler, s -> ItemRequirement.validate(required, s), ExtractionCountMode.UPTO,
|
||||
required.getCount(), true)
|
||||
|
@ -625,7 +627,8 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
|
|||
|
||||
if (!simulate && success) {
|
||||
int amountFound = 0;
|
||||
for (IItemHandler iItemHandler : attachedInventories) {
|
||||
for (LazyOptional<IItemHandler> cap : attachedInventories) {
|
||||
IItemHandler iItemHandler = cap.orElse(EmptyHandler.INSTANCE);
|
||||
amountFound += ItemHelper
|
||||
.extract(iItemHandler, s -> ItemRequirement.validate(required, s), ExtractionCountMode.UPTO,
|
||||
required.getCount(), false)
|
||||
|
@ -916,7 +919,11 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
|
|||
}
|
||||
}
|
||||
checklist.gathered.clear();
|
||||
for (IItemHandler inventory : attachedInventories) {
|
||||
findInventories();
|
||||
for (LazyOptional<IItemHandler> cap : attachedInventories) {
|
||||
if (!cap.isPresent())
|
||||
continue;
|
||||
IItemHandler inventory = cap.orElse(EmptyHandler.INSTANCE);
|
||||
for (int slot = 0; slot < inventory.getSlots(); slot++) {
|
||||
ItemStack stackInSlot = inventory.getStackInSlot(slot);
|
||||
if (inventory.extractItem(slot, 1, true)
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType;
|
|||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -47,7 +46,7 @@ public abstract class TileEntityBehaviour {
|
|||
|
||||
}
|
||||
|
||||
public void onNeighborChanged(Direction direction) {
|
||||
public void onNeighborChanged(BlockPos neighborPos) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -138,6 +138,13 @@ public class InvManipulationBehaviour extends TileEntityBehaviour {
|
|||
findNewNextTick = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged(BlockPos neighborPos) {
|
||||
BlockFace targetBlockFace = target.getTarget(getWorld(), tileEntity.getPos(), tileEntity.getBlockState());
|
||||
if (targetBlockFace.getConnectedPos().equals(neighborPos))
|
||||
onHandlerInvalidated(targetCapability);
|
||||
}
|
||||
|
||||
protected void onHandlerInvalidated(LazyOptional<IItemHandler> handler) {
|
||||
findNewNextTick = true;
|
||||
targetCapability = LazyOptional.empty();
|
||||
|
@ -167,7 +174,7 @@ public class InvManipulationBehaviour extends TileEntityBehaviour {
|
|||
return amount;
|
||||
}
|
||||
|
||||
protected void findNewCapability() {
|
||||
public void findNewCapability() {
|
||||
BlockFace targetBlockFace = target.getTarget(getWorld(), tileEntity.getPos(), tileEntity.getBlockState())
|
||||
.getOpposite();
|
||||
BlockPos pos = targetBlockFace.getPos();
|
||||
|
|
Loading…
Reference in a new issue