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: 'maven-publish'
version = 'mc1.14.4_v0.2.2a'
version = 'mc1.14.4_v0.2.2b'
group = 'com.simibubi.create'
archivesBaseName = 'create'

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -158,8 +158,21 @@ public class NozzleTileEntity extends SmartTileEntity {
pushingEntities.add(entity);
}
if (!pushing && pushingEntities.size() > 512 && !world.isRemote)
world.createExplosion(null, center.x, center.y, center.z, 6, Mode.BREAK);
for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext();) {
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
public float getAddedStressCapacity() {
public float calculateAddedStressCapacity() {
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.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.BlockItemUseContext;
@ -86,7 +87,8 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen
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;
}

View file

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

View file

@ -125,7 +125,11 @@ public class BeltInventory {
if (segmentBefore != -1 && current.locked) {
BeltTileEntity beltSegment = BeltHelper.getBeltAtSegment(belt, segmentBefore);
if (beltSegment != null) {
// wait in case belt isnt initialized yet
if (current.locked && beltSegment.trackerUpdateTag != null)
continue;
current.locked = false;
List<BeltAttachmentState> attachments = beltSegment.attachmentTracker.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.HorizontalBlock;
import net.minecraft.block.material.PushReaction;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.IntegerProperty;
@ -87,7 +88,8 @@ public class StockswitchBlock extends HorizontalBlock implements ITE<Stockswitch
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
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;
}

View file

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

View file

@ -4,7 +4,7 @@ loaderVersion="[28,)"
[[mods]]
modId="create"
version="mc1.14-0.2.2a"
version="mc1.14-0.2.2b"
displayName="Create"
#updateJSONURL=""
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:sand_paper_secret": "9001 Grit 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:mixer": "Mixin' it Up",
"advancement.create:mixer.desc": "Create a Mechanical Mixer.",