From 8dd2f1dbf658f1e29bb67616c2d710717ec10dea Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Thu, 5 Aug 2021 17:05:13 +0200 Subject: [PATCH] Schematic Problematic - Fixed ammo-specific fire damage not dropping cooked drops from killed entities - Fixed Schematicannons not visually aiming toward current block trajectory - Fixed placed Schematics using smaller boundaries than the original - Added the option to enable/disable placing air blocks with instant creative schematic printing - Added safety check for Missing/Migrated filter attributes #2065 - Added safety check for Crushing wheels near unloaded blocks - Added safety check for instant printing an invalid Schematic --- gradle.properties | 2 +- src/main/java/com/simibubi/create/Create.java | 2 +- .../crusher/CrushingWheelControllerBlock.java | 6 +++-- .../weapons/PotatoCannonProjectileTypes.java | 16 ++++++++++--- .../weapons/PotatoProjectileEntity.java | 2 ++ .../logistics/item/filter/FilterItem.java | 2 ++ .../content/schematics/SchematicPrinter.java | 23 +++++++++++++++---- .../packet/SchematicPlacePacket.java | 9 ++++++++ .../create/foundation/config/CSchematics.java | 3 +++ src/main/resources/META-INF/mods.toml | 2 +- 10 files changed, 54 insertions(+), 13 deletions(-) diff --git a/gradle.properties b/gradle.properties index 190398720..4da5ad71c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ org.gradle.jvmargs = -Xmx3G org.gradle.daemon = false # mod version info -mod_version = 0.3.2c +mod_version = 0.3.2d minecraft_version = 1.16.5 forge_version = 36.2.0 diff --git a/src/main/java/com/simibubi/create/Create.java b/src/main/java/com/simibubi/create/Create.java index a5bc411e7..6ab5657a9 100644 --- a/src/main/java/com/simibubi/create/Create.java +++ b/src/main/java/com/simibubi/create/Create.java @@ -58,7 +58,7 @@ public class Create { public static final String ID = "create"; public static final String NAME = "Create"; - public static final String VERSION = "0.3.2c"; + public static final String VERSION = "0.3.2d"; public static final Logger LOGGER = LogManager.getLogger(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerBlock.java index 3184f7f3b..b136458b1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerBlock.java @@ -156,8 +156,10 @@ public class CrushingWheelControllerBlock extends DirectionalBlock continue; if (neighbour.getValue(BlockStateProperties.AXIS) == d.getAxis()) continue; - KineticTileEntity wheelTe = (KineticTileEntity) world.getBlockEntity(pos.relative(d)); - te.crushingspeed = Math.abs(wheelTe.getSpeed() / 50f); + TileEntity adjTe = world.getBlockEntity(pos.relative(d)); + if (!(adjTe instanceof KineticTileEntity)) + continue; + te.crushingspeed = Math.abs(((KineticTileEntity) adjTe).getSpeed() / 50f); te.sendData(); break; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonProjectileTypes.java b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonProjectileTypes.java index 0d19ad0a9..cb1159fbe 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonProjectileTypes.java +++ b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonProjectileTypes.java @@ -77,7 +77,7 @@ public class PotatoCannonProjectileTypes { .velocity(1.25f) .knockback(0.5f) .renderTumbling() - .onEntityHit(setFire(3)) + .preEntityHit(setFire(3)) .registerAndAssign(Items.BAKED_POTATO), CARROT = create("carrot").damage(4) @@ -247,7 +247,7 @@ public class PotatoCannonProjectileTypes { .velocity(1.1f) .renderTumbling() .sticky() - .onEntityHit(setFire(12)) + .preEntityHit(setFire(12)) .soundPitch(1.0f) .registerAndAssign(AllItems.BLAZE_CAKE.get()) ; @@ -286,7 +286,8 @@ public class PotatoCannonProjectileTypes { private float fwoompPitch = 1; private boolean sticky = false; private PotatoProjectileRenderMode renderMode = new PotatoProjectileRenderMode.Billboard(); - private Predicate onEntityHit = e -> false; + private Predicate preEntityHit = e -> false; // True if hit should be canceled + private Predicate onEntityHit = e -> false; // True if shouldn't recover projectile private BiPredicate onBlockHit = (w, ray) -> false; public float getGravityMultiplier() { @@ -327,6 +328,10 @@ public class PotatoCannonProjectileTypes { public boolean isSticky() { return sticky; } + public boolean preEntityHit(EntityRayTraceResult ray) { + return preEntityHit.test(ray); + } + public boolean onEntityHit(EntityRayTraceResult ray) { return onEntityHit.test(ray); } @@ -542,6 +547,11 @@ public class PotatoCannonProjectileTypes { return this; } + public Builder preEntityHit(Predicate callback) { + result.preEntityHit = callback; + return this; + } + public Builder onEntityHit(Predicate callback) { result.onEntityHit = callback; return this; diff --git a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileEntity.java index 6d7fd45db..0cd481f15 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileEntity.java @@ -190,6 +190,8 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements if (target instanceof WitherEntity && ((WitherEntity) target).isPowered()) return; + if (projectileType.preEntityHit(ray)) + return; boolean targetIsEnderman = target.getType() == EntityType.ENDERMAN; int k = target.getRemainingFireTicks(); diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterItem.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterItem.java index b6685de89..b971d7cda 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterItem.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterItem.java @@ -220,6 +220,8 @@ public class FilterItem extends Item implements INamedContainerProvider { for (INBT inbt : attributes) { CompoundNBT compound = (CompoundNBT) inbt; ItemAttribute attribute = ItemAttribute.fromNBT(compound); + if (attribute == null) + continue; boolean matches = attribute.appliesTo(stack, world) != compound.getBoolean("Inverted"); if (matches) { diff --git a/src/main/java/com/simibubi/create/content/schematics/SchematicPrinter.java b/src/main/java/com/simibubi/create/content/schematics/SchematicPrinter.java index 99dd33f7a..906a907fe 100644 --- a/src/main/java/com/simibubi/create/content/schematics/SchematicPrinter.java +++ b/src/main/java/com/simibubi/create/content/schematics/SchematicPrinter.java @@ -51,7 +51,14 @@ public class SchematicPrinter { public void fromTag(CompoundNBT compound, boolean clientPacket) { if (compound.contains("CurrentPos")) currentPos = NBTUtil.readBlockPos(compound.getCompound("CurrentPos")); - + if (clientPacket) { + schematicLoaded = false; + if (compound.contains("Anchor")) { + schematicAnchor = NBTUtil.readBlockPos(compound.getCompound("Anchor")); + schematicLoaded = true; + } + } + printingEntityIndex = compound.getInt("EntityProgress"); printStage = PrintStage.valueOf(compound.getString("PrintStage")); compound.getList("DeferredBlocks", 10).stream() @@ -62,7 +69,9 @@ public class SchematicPrinter { public void write(CompoundNBT compound) { if (currentPos != null) compound.put("CurrentPos", NBTUtil.writeBlockPos(currentPos)); - + if (schematicAnchor != null) + compound.put("Anchor", NBTUtil.writeBlockPos(schematicAnchor)); + compound.putInt("EntityProgress", printingEntityIndex); compound.putString("PrintStage", printStage.name()); ListNBT tagDeferredBlocks = new ListNBT(); @@ -78,15 +87,19 @@ public class SchematicPrinter { Template activeTemplate = SchematicItem.loadSchematic(blueprint); PlacementSettings settings = SchematicItem.getSettings(blueprint, processNBT); - schematicAnchor = NBTUtil.readBlockPos(blueprint.getTag().getCompound("Anchor")); + schematicAnchor = NBTUtil.readBlockPos(blueprint.getTag() + .getCompound("Anchor")); blockReader = new SchematicWorld(schematicAnchor, originalWorld); activeTemplate.placeInWorldChunk(blockReader, schematicAnchor, settings, blockReader.getRandom()); + BlockPos extraBounds = Template.calculateRelativePosition(settings, activeTemplate.getSize() + .offset(-1, -1, -1)); + blockReader.bounds.expand(new MutableBoundingBox(extraBounds, extraBounds)); + StructureTransform transform = new StructureTransform(settings.getRotationPivot(), Direction.Axis.Y, settings.getRotation(), settings.getMirror()); - for (TileEntity te : blockReader.tileEntities.values()) { + for (TileEntity te : blockReader.tileEntities.values()) transform.apply(te); - } printingEntityIndex = -1; printStage = PrintStage.BLOCKS; diff --git a/src/main/java/com/simibubi/create/content/schematics/packet/SchematicPlacePacket.java b/src/main/java/com/simibubi/create/content/schematics/packet/SchematicPlacePacket.java index 3f6eccd0f..3331040c2 100644 --- a/src/main/java/com/simibubi/create/content/schematics/packet/SchematicPlacePacket.java +++ b/src/main/java/com/simibubi/create/content/schematics/packet/SchematicPlacePacket.java @@ -3,6 +3,7 @@ package com.simibubi.create.content.schematics.packet; import java.util.function.Supplier; import com.simibubi.create.content.schematics.SchematicPrinter; +import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.networking.SimplePacketBase; import com.simibubi.create.foundation.utility.BlockHelper; @@ -38,12 +39,20 @@ public class SchematicPlacePacket extends SimplePacketBase { World world = player.getLevel(); SchematicPrinter printer = new SchematicPrinter(); printer.loadSchematic(stack, world, !player.canUseGameMasterBlocks()); + if (!printer.isLoaded()) + return; + + boolean includeAir = AllConfigs.SERVER.schematics.creativePrintIncludesAir.get(); while (printer.advanceCurrentPos()) { if (!printer.shouldPlaceCurrent(world)) continue; printer.handleCurrentTarget((pos, state, tile) -> { + boolean placingAir = state.getBlock().isAir(state, world, pos); + if (placingAir && !includeAir) + return; + CompoundNBT tileData = tile != null ? tile.save(new CompoundNBT()) : null; BlockHelper.placeSchematicBlock(world, state, pos, null, tileData); }, (pos, entity) -> { diff --git a/src/main/java/com/simibubi/create/foundation/config/CSchematics.java b/src/main/java/com/simibubi/create/foundation/config/CSchematics.java index 21a38ef34..9745a8b84 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CSchematics.java +++ b/src/main/java/com/simibubi/create/foundation/config/CSchematics.java @@ -2,6 +2,7 @@ package com.simibubi.create.foundation.config; public class CSchematics extends ConfigBase { + public ConfigBool creativePrintIncludesAir = b(false, "creativePrintIncludesAir", Comments.creativePrintIncludesAir); public ConfigInt maxSchematics = i(10, 1, "maxSchematics", Comments.maxSchematics); public ConfigInt maxTotalSchematicSize = i(256, 16, "maxSchematics", Comments.kb, Comments.maxSize); public ConfigInt maxSchematicPacketSize = @@ -33,6 +34,8 @@ public class CSchematics extends ConfigBase { static String skips = "Amount of block positions per tick scanned by a running cannon. Higher => Faster"; static String gunpowderWorth = "% of Schematicannon's Fuel filled by 1 Gunpowder."; static String fuelUsage = "% of Schematicannon's Fuel used for each fired block."; + static String creativePrintIncludesAir = + "Whether placing a Schematic directly in Creative Mode should replace world blocks with Air"; } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index b3457e6a6..c932c8408 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -5,7 +5,7 @@ license="MIT" [[mods]] modId="create" -version="v0.3.2c for 1.16.5" +version="v0.3.2d" displayName="Create" #updateJSONURL="" displayURL="https://www.curseforge.com/minecraft/mc-mods/create"