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
This commit is contained in:
simibubi 2021-08-05 17:05:13 +02:00
parent 468435e1a0
commit 8dd2f1dbf6
10 changed files with 54 additions and 13 deletions

View file

@ -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

View file

@ -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();

View file

@ -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;
}

View file

@ -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<EntityRayTraceResult> onEntityHit = e -> false;
private Predicate<EntityRayTraceResult> preEntityHit = e -> false; // True if hit should be canceled
private Predicate<EntityRayTraceResult> onEntityHit = e -> false; // True if shouldn't recover projectile
private BiPredicate<IWorld, BlockRayTraceResult> 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<EntityRayTraceResult> callback) {
result.preEntityHit = callback;
return this;
}
public Builder onEntityHit(Predicate<EntityRayTraceResult> callback) {
result.onEntityHit = callback;
return this;

View file

@ -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();

View file

@ -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) {

View file

@ -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;

View file

@ -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) -> {

View file

@ -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";
}
}

View file

@ -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"