mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-13 05:54:17 +01:00
The Frame Train
- Fixed modded signs getting wiped when moved by contraption or printed in a schematic - Added schematic compatibility for the mod "framed blocks"
This commit is contained in:
parent
4d04a16fbb
commit
c66827c43e
@ -203,6 +203,7 @@ dependencies {
|
|||||||
// implementation fg.deobf("curse.maven:druidcraft-340991:3101903")
|
// implementation fg.deobf("curse.maven:druidcraft-340991:3101903")
|
||||||
|
|
||||||
// implementation fg.deobf("com.ferreusveritas.dynamictrees:DynamicTrees-1.16.5:0.10.0-Beta25")
|
// implementation fg.deobf("com.ferreusveritas.dynamictrees:DynamicTrees-1.16.5:0.10.0-Beta25")
|
||||||
|
// runtimeOnly fg.deobf("curse.maven:framedblocks-441647:4567924")
|
||||||
// runtimeOnly fg.deobf("curse.maven:galosphere-631098:4398234")
|
// runtimeOnly fg.deobf("curse.maven:galosphere-631098:4398234")
|
||||||
// runtimeOnly fg.deobf("curse.maven:elementary-ores-332609:3956498")
|
// runtimeOnly fg.deobf("curse.maven:elementary-ores-332609:3956498")
|
||||||
// runtimeOnly fg.deobf("curse.maven:flib-661261:3956196")
|
// runtimeOnly fg.deobf("curse.maven:flib-661261:3956196")
|
||||||
|
@ -25,7 +25,7 @@ registrate_version = MC1.18.2-1.1.3
|
|||||||
flywheel_minecraft_version = 1.18.2
|
flywheel_minecraft_version = 1.18.2
|
||||||
flywheel_version = 0.6.10-105
|
flywheel_version = 0.6.10-105
|
||||||
jei_minecraft_version = 1.18.2
|
jei_minecraft_version = 1.18.2
|
||||||
jei_version = 9.7.0.209
|
jei_version = 9.7.2.277
|
||||||
curios_minecraft_version = 1.18.2
|
curios_minecraft_version = 1.18.2
|
||||||
curios_version = 5.0.7.0
|
curios_version = 5.0.7.0
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package com.simibubi.create;
|
|||||||
|
|
||||||
import static com.simibubi.create.AllTags.NameSpace.CURIOS;
|
import static com.simibubi.create.AllTags.NameSpace.CURIOS;
|
||||||
import static com.simibubi.create.AllTags.NameSpace.FORGE;
|
import static com.simibubi.create.AllTags.NameSpace.FORGE;
|
||||||
import static com.simibubi.create.AllTags.NameSpace.GS;
|
|
||||||
import static com.simibubi.create.AllTags.NameSpace.MOD;
|
import static com.simibubi.create.AllTags.NameSpace.MOD;
|
||||||
import static com.simibubi.create.AllTags.NameSpace.QUARK;
|
import static com.simibubi.create.AllTags.NameSpace.QUARK;
|
||||||
import static com.simibubi.create.AllTags.NameSpace.TIC;
|
import static com.simibubi.create.AllTags.NameSpace.TIC;
|
||||||
|
@ -6,6 +6,8 @@ import java.util.function.Supplier;
|
|||||||
import com.simibubi.create.foundation.utility.Lang;
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.level.ItemLike;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
@ -25,6 +27,7 @@ public enum Mods {
|
|||||||
SOPHISTICATEDSTORAGE,
|
SOPHISTICATEDSTORAGE,
|
||||||
STORAGEDRAWERS,
|
STORAGEDRAWERS,
|
||||||
TCONSTRUCT,
|
TCONSTRUCT,
|
||||||
|
FRAMEDBLOCKS,
|
||||||
XLPACKETS,
|
XLPACKETS,
|
||||||
MODERNUI;
|
MODERNUI;
|
||||||
|
|
||||||
@ -49,6 +52,19 @@ public enum Mods {
|
|||||||
return ForgeRegistries.BLOCKS.getValue(rl(id));
|
return ForgeRegistries.BLOCKS.getValue(rl(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Item getItem(String id) {
|
||||||
|
return ForgeRegistries.ITEMS.getValue(rl(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(ItemLike entry) {
|
||||||
|
if (!isLoaded())
|
||||||
|
return false;
|
||||||
|
Item asItem = entry.asItem();
|
||||||
|
return asItem != null && asItem.getRegistryName()
|
||||||
|
.getNamespace()
|
||||||
|
.equals(id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a boolean of whether the mod is loaded or not based on mod id
|
* @return a boolean of whether the mod is loaded or not based on mod id
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,71 @@
|
|||||||
|
package com.simibubi.create.compat.framedblocks;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.simibubi.create.compat.Mods;
|
||||||
|
import com.simibubi.create.content.schematics.requirement.ItemRequirement;
|
||||||
|
import com.simibubi.create.content.schematics.requirement.ItemRequirement.ItemUseType;
|
||||||
|
import com.simibubi.create.content.schematics.requirement.ItemRequirement.StackRequirement;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
public class FramedBlocksInSchematics {
|
||||||
|
|
||||||
|
static final List<String> KEYS_TO_RETAIN =
|
||||||
|
List.of("intangible", "glowing", "reinforced", "camo_stack", "camo_stack_two", "camo_state", "camo_state_two");
|
||||||
|
|
||||||
|
public static CompoundTag prepareBlockEntityData(BlockState blockState, BlockEntity blockEntity) {
|
||||||
|
CompoundTag data = null;
|
||||||
|
if (blockEntity == null)
|
||||||
|
return data;
|
||||||
|
|
||||||
|
data = blockEntity.saveWithFullMetadata();
|
||||||
|
|
||||||
|
List<String> keysToRemove = new ArrayList<>();
|
||||||
|
for (String key : data.getAllKeys())
|
||||||
|
if (!KEYS_TO_RETAIN.contains(key))
|
||||||
|
keysToRemove.add(key);
|
||||||
|
for (String key : keysToRemove)
|
||||||
|
data.remove(key);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemRequirement getRequiredItems(BlockState blockState, BlockEntity blockEntity) {
|
||||||
|
if (blockEntity == null)
|
||||||
|
return ItemRequirement.NONE;
|
||||||
|
|
||||||
|
CompoundTag data = blockEntity.saveWithFullMetadata();
|
||||||
|
List<StackRequirement> list = new ArrayList<>();
|
||||||
|
|
||||||
|
if (data.getBoolean("intangible"))
|
||||||
|
list.add(new StackRequirement(new ItemStack(Items.PHANTOM_MEMBRANE), ItemUseType.CONSUME));
|
||||||
|
|
||||||
|
if (data.getBoolean("glowing"))
|
||||||
|
list.add(new StackRequirement(new ItemStack(Items.GLOWSTONE_DUST), ItemUseType.CONSUME));
|
||||||
|
|
||||||
|
if (data.getBoolean("reinforced"))
|
||||||
|
list.add(new StackRequirement(new ItemStack(Mods.FRAMEDBLOCKS.getItem("framed_reinforcement")),
|
||||||
|
ItemUseType.CONSUME));
|
||||||
|
|
||||||
|
if (data.contains("camo_stack"))
|
||||||
|
addCamoStack(data.getCompound("camo_stack"), list);
|
||||||
|
|
||||||
|
if (data.contains("camo_stack_two"))
|
||||||
|
addCamoStack(data.getCompound("camo_stack_two"), list);
|
||||||
|
|
||||||
|
return new ItemRequirement(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addCamoStack(CompoundTag tag, List<StackRequirement> list) {
|
||||||
|
ItemStack itemStack = ItemStack.of(tag);
|
||||||
|
if (!itemStack.isEmpty())
|
||||||
|
list.add(new StackRequirement(itemStack, ItemUseType.CONSUME));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1077,7 +1077,7 @@ public abstract class Contraption {
|
|||||||
|
|
||||||
CompoundTag tag = block.nbt;
|
CompoundTag tag = block.nbt;
|
||||||
if (blockEntity != null)
|
if (blockEntity != null)
|
||||||
tag = NBTProcessors.process(blockEntity, tag, false);
|
tag = NBTProcessors.process(state, blockEntity, tag, false);
|
||||||
if (blockEntity != null && tag != null) {
|
if (blockEntity != null && tag != null) {
|
||||||
tag.putInt("x", targetPos.getX());
|
tag.putInt("x", targetPos.getX());
|
||||||
tag.putInt("y", targetPos.getY());
|
tag.putInt("y", targetPos.getY());
|
||||||
|
@ -234,7 +234,7 @@ public abstract class ZapperItem extends Item implements CustomArmPoseItem {
|
|||||||
if (data != null && AllBlockTags.SAFE_NBT.matches(state)) {
|
if (data != null && AllBlockTags.SAFE_NBT.matches(state)) {
|
||||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||||
if (blockEntity != null) {
|
if (blockEntity != null) {
|
||||||
data = NBTProcessors.process(blockEntity, data, !player.isCreative());
|
data = NBTProcessors.process(state, blockEntity, data, !player.isCreative());
|
||||||
if (data == null)
|
if (data == null)
|
||||||
return;
|
return;
|
||||||
data.putInt("x", pos.getX());
|
data.putInt("x", pos.getX());
|
||||||
|
@ -35,7 +35,7 @@ public class SchematicProcessor extends StructureProcessor {
|
|||||||
if (info.nbt != null && info.state.hasBlockEntity()) {
|
if (info.nbt != null && info.state.hasBlockEntity()) {
|
||||||
BlockEntity be = ((EntityBlock) info.state.getBlock()).newBlockEntity(info.pos, info.state);
|
BlockEntity be = ((EntityBlock) info.state.getBlock()).newBlockEntity(info.pos, info.state);
|
||||||
if (be != null) {
|
if (be != null) {
|
||||||
CompoundTag nbt = NBTProcessors.process(be, info.nbt, false);
|
CompoundTag nbt = NBTProcessors.process(info.state, be, info.nbt, false);
|
||||||
if (nbt != info.nbt)
|
if (nbt != info.nbt)
|
||||||
return new StructureTemplate.StructureBlockInfo(info.pos, info.state, nbt);
|
return new StructureTemplate.StructureBlockInfo(info.pos, info.state, nbt);
|
||||||
}
|
}
|
||||||
|
@ -163,6 +163,8 @@ public class SchematicHandler {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
schematic.placeInWorld(w, pos, pos, placementSettings, w.getRandom(), Block.UPDATE_CLIENTS);
|
schematic.placeInWorld(w, pos, pos, placementSettings, w.getRandom(), Block.UPDATE_CLIENTS);
|
||||||
|
for (BlockEntity blockEntity : w.getBlockEntities())
|
||||||
|
blockEntity.setLevel(w);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Minecraft.getInstance().player.displayClientMessage(Lang.translate("schematic.error")
|
Minecraft.getInstance().player.displayClientMessage(Lang.translate("schematic.error")
|
||||||
.component(), false);
|
.component(), false);
|
||||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.simibubi.create.compat.framedblocks.FramedBlocksInSchematics;
|
||||||
import com.simibubi.create.foundation.data.recipe.Mods;
|
import com.simibubi.create.foundation.data.recipe.Mods;
|
||||||
import com.simibubi.create.foundation.utility.NBTProcessors;
|
import com.simibubi.create.foundation.utility.NBTProcessors;
|
||||||
|
|
||||||
@ -71,6 +72,9 @@ public class ItemRequirement {
|
|||||||
if (be instanceof ISpecialBlockEntityItemRequirement specialBE)
|
if (be instanceof ISpecialBlockEntityItemRequirement specialBE)
|
||||||
requirement = requirement.union(specialBE.getRequiredItems(state));
|
requirement = requirement.union(specialBE.getRequiredItems(state));
|
||||||
|
|
||||||
|
if (com.simibubi.create.compat.Mods.FRAMEDBLOCKS.contains(block))
|
||||||
|
requirement = requirement.union(FramedBlocksInSchematics.getRequiredItems(state, be));
|
||||||
|
|
||||||
return requirement;
|
return requirement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package com.simibubi.create.foundation.data.recipe;
|
package com.simibubi.create.foundation.data.recipe;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.ItemLike;
|
|
||||||
|
|
||||||
public enum Mods {
|
public enum Mods {
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.AllTags.AllBlockTags;
|
import com.simibubi.create.AllTags.AllBlockTags;
|
||||||
|
import com.simibubi.create.compat.Mods;
|
||||||
|
import com.simibubi.create.compat.framedblocks.FramedBlocksInSchematics;
|
||||||
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
|
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
|
||||||
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock;
|
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock;
|
||||||
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock.HeatLevel;
|
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock.HeatLevel;
|
||||||
@ -243,15 +245,18 @@ public class BlockHelper {
|
|||||||
CompoundTag data = null;
|
CompoundTag data = null;
|
||||||
if (blockEntity == null)
|
if (blockEntity == null)
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
if (AllBlockTags.SAFE_NBT.matches(blockState)) {
|
if (AllBlockTags.SAFE_NBT.matches(blockState)) {
|
||||||
data = blockEntity.saveWithFullMetadata();
|
data = blockEntity.saveWithFullMetadata();
|
||||||
data = NBTProcessors.process(blockEntity, data, true);
|
|
||||||
} else if (blockEntity instanceof IPartialSafeNBT) {
|
} else if (blockEntity instanceof IPartialSafeNBT) {
|
||||||
data = new CompoundTag();
|
data = new CompoundTag();
|
||||||
((IPartialSafeNBT) blockEntity).writeSafe(data);
|
((IPartialSafeNBT) blockEntity).writeSafe(data);
|
||||||
data = NBTProcessors.process(blockEntity, data, true);
|
|
||||||
}
|
} else if (Mods.FRAMEDBLOCKS.contains(blockState.getBlock()))
|
||||||
return data;
|
data = FramedBlocksInSchematics.prepareBlockEntityData(blockState, blockEntity);
|
||||||
|
|
||||||
|
return NBTProcessors.process(blockState, blockEntity, data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void placeSchematicBlock(Level world, BlockState state, BlockPos target, ItemStack stack,
|
public static void placeSchematicBlock(Level world, BlockState state, BlockPos target, ItemStack stack,
|
||||||
|
@ -13,11 +13,13 @@ import net.minecraft.nbt.CompoundTag;
|
|||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.world.item.EnchantedBookItem;
|
import net.minecraft.world.item.EnchantedBookItem;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
|
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
public final class NBTProcessors {
|
public final class NBTProcessors {
|
||||||
|
|
||||||
@ -34,13 +36,6 @@ public final class NBTProcessors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
addProcessor(BlockEntityType.SIGN, data -> {
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
|
||||||
if (textComponentHasClickEvent(data.getString("Text" + (i + 1))))
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
});
|
|
||||||
addProcessor(BlockEntityType.LECTERN, data -> {
|
addProcessor(BlockEntityType.LECTERN, data -> {
|
||||||
if (!data.contains("Book", Tag.TAG_COMPOUND))
|
if (!data.contains("Book", Tag.TAG_COMPOUND))
|
||||||
return data;
|
return data;
|
||||||
@ -64,6 +59,14 @@ public final class NBTProcessors {
|
|||||||
addProcessor(AllBlockEntityTypes.PLACARD.get(), itemProcessor("Item"));
|
addProcessor(AllBlockEntityTypes.PLACARD.get(), itemProcessor("Item"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Triggered by block tag, not BE type
|
||||||
|
private static final UnaryOperator<CompoundTag> signProcessor = data -> {
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
if (textComponentHasClickEvent(data.getString("Text" + (i + 1))))
|
||||||
|
return null;
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
public static UnaryOperator<CompoundTag> itemProcessor(String tagKey) {
|
public static UnaryOperator<CompoundTag> itemProcessor(String tagKey) {
|
||||||
return data -> {
|
return data -> {
|
||||||
CompoundTag compound = data.getCompound(tagKey);
|
CompoundTag compound = data.getCompound(tagKey);
|
||||||
@ -117,7 +120,7 @@ public final class NBTProcessors {
|
|||||||
private NBTProcessors() {}
|
private NBTProcessors() {}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static CompoundTag process(BlockEntity blockEntity, CompoundTag compound, boolean survival) {
|
public static CompoundTag process(BlockState blockState, BlockEntity blockEntity, CompoundTag compound, boolean survival) {
|
||||||
if (compound == null)
|
if (compound == null)
|
||||||
return null;
|
return null;
|
||||||
BlockEntityType<?> type = blockEntity.getType();
|
BlockEntityType<?> type = blockEntity.getType();
|
||||||
@ -129,6 +132,8 @@ public final class NBTProcessors {
|
|||||||
.apply(compound);
|
.apply(compound);
|
||||||
if (blockEntity instanceof SpawnerBlockEntity)
|
if (blockEntity instanceof SpawnerBlockEntity)
|
||||||
return compound;
|
return compound;
|
||||||
|
if (blockState.is(BlockTags.SIGNS))
|
||||||
|
return signProcessor.apply(compound);
|
||||||
if (blockEntity.onlyOpCanSetNbt())
|
if (blockEntity.onlyOpCanSetNbt())
|
||||||
return null;
|
return null;
|
||||||
return compound;
|
return compound;
|
||||||
|
Loading…
Reference in New Issue
Block a user