mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-13 05:54:17 +01:00
Fix funnel filter dupe
This commit is contained in:
parent
c5447d5b9c
commit
4a15fbcec3
@ -241,11 +241,11 @@ public abstract class ZapperItem extends Item {
|
||||
return UseAction.NONE;
|
||||
}
|
||||
|
||||
public static void setTileData(World world, BlockPos pos, BlockState state, CompoundNBT data) {
|
||||
public static void setTileData(World world, BlockPos pos, BlockState state, CompoundNBT data, PlayerEntity player) {
|
||||
if (data != null && AllBlockTags.SAFE_NBT.matches(state)) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile != null) {
|
||||
data = NBTProcessors.process(tile, data, true);
|
||||
data = NBTProcessors.process(tile, data, !player.isCreative());
|
||||
if (data == null)
|
||||
return;
|
||||
data.putInt("x", pos.getX());
|
||||
|
@ -135,7 +135,7 @@ public class BlockzapperItem extends ZapperItem {
|
||||
blocksnapshot.restore(true, false);
|
||||
return false;
|
||||
}
|
||||
setTileData(world, placed, state, data);
|
||||
setTileData(world, placed, state, data, player);
|
||||
|
||||
if (player instanceof ServerPlayerEntity && world instanceof ServerWorld) {
|
||||
ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player;
|
||||
|
@ -10,6 +10,7 @@ import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@ -36,7 +37,7 @@ public enum TerrainTools {
|
||||
return this != Clear && this != Flatten;
|
||||
}
|
||||
|
||||
public void run(World world, List<BlockPos> targetPositions, Direction facing, @Nullable BlockState paintedState, @Nullable CompoundNBT data) {
|
||||
public void run(World world, List<BlockPos> targetPositions, Direction facing, @Nullable BlockState paintedState, @Nullable CompoundNBT data, PlayerEntity player) {
|
||||
switch (this) {
|
||||
case Clear:
|
||||
targetPositions.forEach(p -> world.setBlockState(p, Blocks.AIR.getDefaultState()));
|
||||
@ -47,7 +48,7 @@ public enum TerrainTools {
|
||||
if (!isReplaceable(toReplace))
|
||||
return;
|
||||
world.setBlockState(p, paintedState);
|
||||
ZapperItem.setTileData(world, p, paintedState, data);
|
||||
ZapperItem.setTileData(world, p, paintedState, data, player);
|
||||
});
|
||||
break;
|
||||
case Flatten:
|
||||
@ -67,13 +68,13 @@ public enum TerrainTools {
|
||||
if (!isReplaceable(toReplace))
|
||||
return;
|
||||
world.setBlockState(p, paintedState);
|
||||
ZapperItem.setTileData(world, p, paintedState, data);
|
||||
ZapperItem.setTileData(world, p, paintedState, data, player);
|
||||
});
|
||||
break;
|
||||
case Place:
|
||||
targetPositions.forEach(p -> {
|
||||
world.setBlockState(p, paintedState);
|
||||
ZapperItem.setTileData(world, p, paintedState, data);
|
||||
ZapperItem.setTileData(world, p, paintedState, data, player);
|
||||
});
|
||||
break;
|
||||
case Replace:
|
||||
@ -82,7 +83,7 @@ public enum TerrainTools {
|
||||
if (isReplaceable(toReplace))
|
||||
return;
|
||||
world.setBlockState(p, paintedState);
|
||||
ZapperItem.setTileData(world, p, paintedState, data);
|
||||
ZapperItem.setTileData(world, p, paintedState, data, player);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class WorldshaperItem extends ZapperItem {
|
||||
for (BlockPos blockPos : brush.getIncludedPositions())
|
||||
affectedPositions.add(targetPos.add(blockPos));
|
||||
PlacementPatterns.applyPattern(affectedPositions, stack);
|
||||
tool.run(world, affectedPositions, raytrace.getFace(), stateToUse, data);
|
||||
tool.run(world, affectedPositions, raytrace.getFace(), stateToUse, data, player);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -6,6 +6,10 @@ import java.util.function.UnaryOperator;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.content.logistics.item.filter.FilterItem;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
@ -35,6 +39,14 @@ public final class NBTProcessors {
|
||||
}
|
||||
return data;
|
||||
});
|
||||
addSurvivalProcessor(AllTileEntities.FUNNEL.get(), data -> {
|
||||
if (data.contains("Filter")) {
|
||||
ItemStack filter = ItemStack.read(data.getCompound("Filter"));
|
||||
if (filter.getItem() instanceof FilterItem)
|
||||
data.remove("Filter");
|
||||
}
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
private NBTProcessors() {
|
||||
|
Loading…
Reference in New Issue
Block a user