A cure to darkness

- Kinetic blocks no longer cause chunks to lose all block light information
- Stockpile switch and sequencer no longer open the GUI to the wrong players
- Belt items no longer skip blocking attachments while loaded in
- Nozzle explosions no longer cause block damage
- PSIs no longer transfer an excess of items, deleting them in the process
This commit is contained in:
simibubi 2020-04-10 21:43:28 +02:00
parent 72ddc1251a
commit 3c0b55ac1d
17 changed files with 74 additions and 58 deletions

View file

@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
version = 'mc1.14.4_v0.2.2a' version = 'mc1.14.4_v0.2.2b'
group = 'com.simibubi.create' group = 'com.simibubi.create'
archivesBaseName = 'create' archivesBaseName = 'create'

View file

@ -38,12 +38,12 @@ public class KineticNetwork {
return; return;
if (te.isSource()) { if (te.isSource()) {
unloadedCapacity -= lastCapacity * getStressMultiplierForSpeed(te.getGeneratedSpeed()); unloadedCapacity -= lastCapacity * getStressMultiplierForSpeed(te.getGeneratedSpeed());
float addedStressCapacity = te.getAddedStressCapacity(); float addedStressCapacity = te.calculateAddedStressCapacity();
sources.put(te, addedStressCapacity); sources.put(te, addedStressCapacity);
} }
unloadedStress -= lastStress * getStressMultiplierForSpeed(te.getTheoreticalSpeed()); unloadedStress -= lastStress * getStressMultiplierForSpeed(te.getTheoreticalSpeed());
float stressApplied = te.getStressApplied(); float stressApplied = te.calculateStressApplied();
members.put(te, stressApplied); members.put(te, stressApplied);
unloadedMembers--; unloadedMembers--;
@ -59,8 +59,8 @@ public class KineticNetwork {
if (members.containsKey(te)) if (members.containsKey(te))
return; return;
if (te.isSource()) if (te.isSource())
sources.put(te, te.getAddedStressCapacity()); sources.put(te, te.calculateAddedStressCapacity());
members.put(te, te.getStressApplied()); members.put(te, te.calculateStressApplied());
te.updateFromNetwork(currentCapacity, currentStress, getSize()); te.updateFromNetwork(currentCapacity, currentStress, getSize());
te.networkDirty = true; te.networkDirty = true;
} }

View file

@ -55,7 +55,7 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity {
public boolean addToGoggleTooltip(List<String> tooltip, boolean isPlayerSneaking) { public boolean addToGoggleTooltip(List<String> tooltip, boolean isPlayerSneaking) {
boolean added = super.addToGoggleTooltip(tooltip, isPlayerSneaking); boolean added = super.addToGoggleTooltip(tooltip, isPlayerSneaking);
float stressBase = getAddedStressCapacity(); float stressBase = calculateAddedStressCapacity();
if (stressBase != 0 && IRotate.StressImpact.isEnabled()) { if (stressBase != 0 && IRotate.StressImpact.isEnabled()) {
tooltip.add(spacing + Lang.translate("gui.goggles.generator_stats")); tooltip.add(spacing + Lang.translate("gui.goggles.generator_stats"));
tooltip.add(spacing + TextFormatting.GRAY + Lang.translate("tooltip.capacityProvided")); tooltip.add(spacing + TextFormatting.GRAY + Lang.translate("tooltip.capacityProvided"));
@ -97,8 +97,8 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity {
if (hasNetwork() && speed != 0) { if (hasNetwork() && speed != 0) {
KineticNetwork network = getOrCreateNetwork(); KineticNetwork network = getOrCreateNetwork();
notifyStressCapacityChange(getAddedStressCapacity()); notifyStressCapacityChange(calculateAddedStressCapacity());
getOrCreateNetwork().updateStressFor(this, getStressApplied()); getOrCreateNetwork().updateStressFor(this, calculateStressApplied());
network.updateStress(); network.updateStress();
} }
@ -112,7 +112,7 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity {
if (speed == 0) { if (speed == 0) {
if (hasSource()) { if (hasSource()) {
notifyStressCapacityChange(0); notifyStressCapacityChange(0);
getOrCreateNetwork().updateStressFor(this, getStressApplied()); getOrCreateNetwork().updateStressFor(this, calculateStressApplied());
return; return;
} }
detachKinetics(); detachKinetics();

View file

@ -139,20 +139,22 @@ public abstract class KineticTileEntity extends SmartTileEntity
} }
} }
public float getAddedStressCapacity() { public float calculateAddedStressCapacity() {
Map<ResourceLocation, ConfigValue<Double>> capacityMap = AllConfigs.SERVER.kinetics.stressValues.capacities; Map<ResourceLocation, ConfigValue<Double>> capacityMap = AllConfigs.SERVER.kinetics.stressValues.capacities;
ResourceLocation path = getBlockState().getBlock().getRegistryName(); ResourceLocation path = getBlockState().getBlock().getRegistryName();
if (!capacityMap.containsKey(path))
return 0; float capacity = capacityMap.containsKey(path) ? capacityMap.get(path).get().floatValue() : 0;
return capacityMap.get(path).get().floatValue(); this.lastCapacityProvided = capacity;
return capacity;
} }
public float getStressApplied() { public float calculateStressApplied() {
Map<ResourceLocation, ConfigValue<Double>> stressEntries = AllConfigs.SERVER.kinetics.stressValues.impacts; Map<ResourceLocation, ConfigValue<Double>> stressEntries = AllConfigs.SERVER.kinetics.stressValues.impacts;
ResourceLocation path = getBlockState().getBlock().getRegistryName(); ResourceLocation path = getBlockState().getBlock().getRegistryName();
if (!stressEntries.containsKey(path))
return 1; float impact = stressEntries.containsKey(path) ? stressEntries.get(path).get().floatValue() : 1;
return stressEntries.get(path).get().floatValue(); this.lastStressApplied = impact;
return impact;
} }
public void onSpeedChanged(float previousSpeed) { public void onSpeedChanged(float previousSpeed) {
@ -186,13 +188,11 @@ public abstract class KineticTileEntity extends SmartTileEntity
networkTag.putFloat("Stress", stress); networkTag.putFloat("Stress", stress);
networkTag.putFloat("Capacity", capacity); networkTag.putFloat("Capacity", capacity);
networkTag.putInt("Size", networkSize); networkTag.putInt("Size", networkSize);
float stressApplied = getStressApplied(); if (lastStressApplied != 0)
float addedStressCapacity = getAddedStressCapacity(); networkTag.putFloat("AddedStress", lastStressApplied);
if (stressApplied != 0) if (lastCapacityProvided != 0)
networkTag.putFloat("AddedStress", stressApplied); networkTag.putFloat("AddedCapacity", lastCapacityProvided);
if (addedStressCapacity != 0)
networkTag.putFloat("AddedCapacity", addedStressCapacity);
compound.put("Network", networkTag); compound.put("Network", networkTag);
} }
@ -203,7 +203,6 @@ public abstract class KineticTileEntity extends SmartTileEntity
@Override @Override
public void read(CompoundNBT compound) { public void read(CompoundNBT compound) {
speed = compound.getFloat("Speed"); speed = compound.getFloat("Speed");
source = null; source = null;
network = null; network = null;
overStressed = false; overStressed = false;
@ -392,9 +391,9 @@ public abstract class KineticTileEntity extends SmartTileEntity
@Override @Override
public boolean addToGoggleTooltip(List<String> tooltip, boolean isPlayerSneaking) { public boolean addToGoggleTooltip(List<String> tooltip, boolean isPlayerSneaking) {
boolean added = false; boolean added = false;
float stressAtBase = getStressApplied(); float stressAtBase = calculateStressApplied();
if (getStressApplied() != 0 && StressImpact.isEnabled()) { if (calculateStressApplied() != 0 && StressImpact.isEnabled()) {
tooltip.add(spacing + Lang.translate("gui.goggles.kinetic_stats")); tooltip.add(spacing + Lang.translate("gui.goggles.kinetic_stats"));
tooltip.add(spacing + TextFormatting.GRAY + Lang.translate("tooltip.stressImpact")); tooltip.add(spacing + TextFormatting.GRAY + Lang.translate("tooltip.stressImpact"));

View file

@ -102,8 +102,8 @@ public class StorageInterfaceMovement extends MovementBehaviour {
extracting.withAmountThreshold(stack -> { extracting.withAmountThreshold(stack -> {
ItemStack tester = stack.copy(); ItemStack tester = stack.copy();
tester.setCount(64); tester.setCount(tester.getMaxStackSize());
return 64 - ItemHandlerHelper.insertItemStacked(inv, stack, true).getCount(); return stack.getCount() - ItemHandlerHelper.insertItemStacked(inv, stack, true).getCount();
}); });
extracting.setCallback(stack -> { extracting.setCallback(stack -> {

View file

@ -52,13 +52,13 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity imp
} }
@Override @Override
public float getAddedStressCapacity() { public float calculateAddedStressCapacity() {
return isWindmill ? super.getAddedStressCapacity() : 0; return isWindmill ? super.calculateAddedStressCapacity() : 0;
} }
@Override @Override
public float getStressApplied() { public float calculateStressApplied() {
return isWindmill ? 0 : super.getStressApplied(); return isWindmill ? 0 : super.calculateStressApplied();
} }
public void neighbourChanged() { public void neighbourChanged() {

View file

@ -204,7 +204,7 @@ public class CrushingWheelControllerTileEntity extends SyncedTileEntity implemen
@Override @Override
public CompoundNBT write(CompoundNBT compound) { public CompoundNBT write(CompoundNBT compound) {
if (hasEntity() && !isFrozen()) if (hasEntity())
compound.put("Entity", NBTUtil.writeUniqueId(entityUUID)); compound.put("Entity", NBTUtil.writeUniqueId(entityUUID));
compound.put("Inventory", inventory.serializeNBT()); compound.put("Inventory", inventory.serializeNBT());
compound.putFloat("Speed", crushingspeed); compound.putFloat("Speed", crushingspeed);

View file

@ -45,13 +45,13 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity {
} }
@Override @Override
public float getAddedStressCapacity() { public float calculateAddedStressCapacity() {
return isGenerator ? super.getAddedStressCapacity() : 0; return isGenerator ? super.calculateAddedStressCapacity() : 0;
} }
@Override @Override
public float getStressApplied() { public float calculateStressApplied() {
return isGenerator ? 0 : super.getStressApplied(); return isGenerator ? 0 : super.calculateStressApplied();
} }
@Override @Override

View file

@ -158,8 +158,21 @@ public class NozzleTileEntity extends SmartTileEntity {
pushingEntities.add(entity); pushingEntities.add(entity);
} }
if (!pushing && pushingEntities.size() > 512 && !world.isRemote) for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext();) {
world.createExplosion(null, center.x, center.y, center.z, 6, Mode.BREAK); Entity entity = iterator.next();
if (entity.isAlive())
continue;
iterator.remove();
}
if (!pushing && pushingEntities.size() > 256 && !world.isRemote) {
world.createExplosion(null, center.x, center.y, center.z, 2, Mode.NONE);
for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext();) {
Entity entity = iterator.next();
entity.remove();
iterator.remove();
}
}
} }

View file

@ -43,7 +43,7 @@ public class FlywheelTileEntity extends GeneratingKineticTileEntity {
} }
@Override @Override
public float getAddedStressCapacity() { public float calculateAddedStressCapacity() {
return generatedCapacity; return generatedCapacity;
} }

View file

@ -10,6 +10,7 @@ import com.simibubi.create.modules.contraptions.base.RotatedPillarKineticBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
@ -86,7 +87,8 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen
return false; return false;
} }
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> withTileEntityDo(worldIn, pos, this::displayScreen)); if (player instanceof ClientPlayerEntity)
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> withTileEntityDo(worldIn, pos, this::displayScreen));
return true; return true;
} }

View file

@ -56,7 +56,7 @@ public class BeltTileEntity extends KineticTileEntity {
protected BeltInventory inventory; protected BeltInventory inventory;
protected LazyOptional<IItemHandler> itemHandler; protected LazyOptional<IItemHandler> itemHandler;
private CompoundNBT trackerUpdateTag; public CompoundNBT trackerUpdateTag;
public BeltTileEntity() { public BeltTileEntity() {
super(AllTileEntities.BELT.type); super(AllTileEntities.BELT.type);
@ -115,10 +115,10 @@ public class BeltTileEntity extends KineticTileEntity {
} }
@Override @Override
public float getStressApplied() { public float calculateStressApplied() {
if (!isController()) if (!isController())
return 0; return 0;
return super.getStressApplied(); return super.calculateStressApplied();
} }
@Override @Override

View file

@ -125,7 +125,11 @@ public class BeltInventory {
if (segmentBefore != -1 && current.locked) { if (segmentBefore != -1 && current.locked) {
BeltTileEntity beltSegment = BeltHelper.getBeltAtSegment(belt, segmentBefore); BeltTileEntity beltSegment = BeltHelper.getBeltAtSegment(belt, segmentBefore);
if (beltSegment != null) { if (beltSegment != null) {
// wait in case belt isnt initialized yet
if (current.locked && beltSegment.trackerUpdateTag != null)
continue;
current.locked = false; current.locked = false;
List<BeltAttachmentState> attachments = beltSegment.attachmentTracker.attachments; List<BeltAttachmentState> attachments = beltSegment.attachmentTracker.attachments;
for (BeltAttachmentState attachmentState : attachments) { for (BeltAttachmentState attachmentState : attachments) {

View file

@ -8,6 +8,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.HorizontalBlock; import net.minecraft.block.HorizontalBlock;
import net.minecraft.block.material.PushReaction; import net.minecraft.block.material.PushReaction;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.IntegerProperty; import net.minecraft.state.IntegerProperty;
@ -87,7 +88,8 @@ public class StockswitchBlock extends HorizontalBlock implements ITE<Stockswitch
@Override @Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
BlockRayTraceResult hit) { BlockRayTraceResult hit) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> withTileEntityDo(worldIn, pos, this::displayScreen)); if (player instanceof ClientPlayerEntity)
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> withTileEntityDo(worldIn, pos, this::displayScreen));
return true; return true;
} }

View file

@ -162,20 +162,16 @@ public class FlexcrateTileEntity extends SyncedTileEntity implements INamedConta
@Override @Override
public CompoundNBT write(CompoundNBT compound) { public CompoundNBT write(CompoundNBT compound) {
if (!isSecondaryCrate()) { compound.putBoolean("Main", true);
compound.putBoolean("Main", true); compound.putInt("AllowedAmount", allowedAmount);
compound.putInt("AllowedAmount", allowedAmount); compound.put("Inventory", inventory.serializeNBT());
compound.put("Inventory", inventory.serializeNBT());
}
return super.write(compound); return super.write(compound);
} }
@Override @Override
public void read(CompoundNBT compound) { public void read(CompoundNBT compound) {
if (compound.contains("Main")) { allowedAmount = compound.getInt("AllowedAmount");
allowedAmount = compound.getInt("AllowedAmount"); inventory.deserializeNBT(compound.getCompound("Inventory"));
inventory.deserializeNBT(compound.getCompound("Inventory"));
}
super.read(compound); super.read(compound);
} }

View file

@ -4,7 +4,7 @@ loaderVersion="[28,)"
[[mods]] [[mods]]
modId="create" modId="create"
version="mc1.14-0.2.2a" version="mc1.14-0.2.2b"
displayName="Create" displayName="Create"
#updateJSONURL="" #updateJSONURL=""
authors="simibubi" authors="simibubi"

View file

@ -635,7 +635,7 @@
"advancement.create:polished_rose_quartz.desc": "Polish Rose Quartz until you can see through it.", "advancement.create:polished_rose_quartz.desc": "Polish Rose Quartz until you can see through it.",
"advancement.create:sand_paper_secret": "9001 Grit Sand Paper", "advancement.create:sand_paper_secret": "9001 Grit Sand Paper",
"advancement.create:sand_paper_secret.desc": "Use your Sand Paper to sand some Sand Paper.", "advancement.create:sand_paper_secret.desc": "Use your Sand Paper to sand some Sand Paper.",
"advancement.create:press": "'Bonk!' ", "advancement.create:press": "'Bonk!'",
"advancement.create:press.desc": "Make a Mechanical Press and use it to create some Plates.", "advancement.create:press.desc": "Make a Mechanical Press and use it to create some Plates.",
"advancement.create:mixer": "Mixin' it Up", "advancement.create:mixer": "Mixin' it Up",
"advancement.create:mixer.desc": "Create a Mechanical Mixer.", "advancement.create:mixer.desc": "Create a Mechanical Mixer.",