mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-14 14:33:57 +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;
|
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)) {
|
if (data != null && AllBlockTags.SAFE_NBT.matches(state)) {
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
data = NBTProcessors.process(tile, data, true);
|
data = NBTProcessors.process(tile, data, !player.isCreative());
|
||||||
if (data == null)
|
if (data == null)
|
||||||
return;
|
return;
|
||||||
data.putInt("x", pos.getX());
|
data.putInt("x", pos.getX());
|
||||||
|
@ -135,7 +135,7 @@ public class BlockzapperItem extends ZapperItem {
|
|||||||
blocksnapshot.restore(true, false);
|
blocksnapshot.restore(true, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
setTileData(world, placed, state, data);
|
setTileData(world, placed, state, data, player);
|
||||||
|
|
||||||
if (player instanceof ServerPlayerEntity && world instanceof ServerWorld) {
|
if (player instanceof ServerPlayerEntity && world instanceof ServerWorld) {
|
||||||
ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player;
|
ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player;
|
||||||
|
@ -10,6 +10,7 @@ import com.simibubi.create.foundation.utility.Lang;
|
|||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@ -36,7 +37,7 @@ public enum TerrainTools {
|
|||||||
return this != Clear && this != Flatten;
|
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) {
|
switch (this) {
|
||||||
case Clear:
|
case Clear:
|
||||||
targetPositions.forEach(p -> world.setBlockState(p, Blocks.AIR.getDefaultState()));
|
targetPositions.forEach(p -> world.setBlockState(p, Blocks.AIR.getDefaultState()));
|
||||||
@ -47,7 +48,7 @@ public enum TerrainTools {
|
|||||||
if (!isReplaceable(toReplace))
|
if (!isReplaceable(toReplace))
|
||||||
return;
|
return;
|
||||||
world.setBlockState(p, paintedState);
|
world.setBlockState(p, paintedState);
|
||||||
ZapperItem.setTileData(world, p, paintedState, data);
|
ZapperItem.setTileData(world, p, paintedState, data, player);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case Flatten:
|
case Flatten:
|
||||||
@ -67,13 +68,13 @@ public enum TerrainTools {
|
|||||||
if (!isReplaceable(toReplace))
|
if (!isReplaceable(toReplace))
|
||||||
return;
|
return;
|
||||||
world.setBlockState(p, paintedState);
|
world.setBlockState(p, paintedState);
|
||||||
ZapperItem.setTileData(world, p, paintedState, data);
|
ZapperItem.setTileData(world, p, paintedState, data, player);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case Place:
|
case Place:
|
||||||
targetPositions.forEach(p -> {
|
targetPositions.forEach(p -> {
|
||||||
world.setBlockState(p, paintedState);
|
world.setBlockState(p, paintedState);
|
||||||
ZapperItem.setTileData(world, p, paintedState, data);
|
ZapperItem.setTileData(world, p, paintedState, data, player);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case Replace:
|
case Replace:
|
||||||
@ -82,7 +83,7 @@ public enum TerrainTools {
|
|||||||
if (isReplaceable(toReplace))
|
if (isReplaceable(toReplace))
|
||||||
return;
|
return;
|
||||||
world.setBlockState(p, paintedState);
|
world.setBlockState(p, paintedState);
|
||||||
ZapperItem.setTileData(world, p, paintedState, data);
|
ZapperItem.setTileData(world, p, paintedState, data, player);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ public class WorldshaperItem extends ZapperItem {
|
|||||||
for (BlockPos blockPos : brush.getIncludedPositions())
|
for (BlockPos blockPos : brush.getIncludedPositions())
|
||||||
affectedPositions.add(targetPos.add(blockPos));
|
affectedPositions.add(targetPos.add(blockPos));
|
||||||
PlacementPatterns.applyPattern(affectedPositions, stack);
|
PlacementPatterns.applyPattern(affectedPositions, stack);
|
||||||
tool.run(world, affectedPositions, raytrace.getFace(), stateToUse, data);
|
tool.run(world, affectedPositions, raytrace.getFace(), stateToUse, data, player);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,10 @@ import java.util.function.UnaryOperator;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
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.nbt.CompoundNBT;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
@ -35,6 +39,14 @@ public final class NBTProcessors {
|
|||||||
}
|
}
|
||||||
return data;
|
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() {
|
private NBTProcessors() {
|
||||||
|
Loading…
Reference in New Issue
Block a user