Here to ruin the fun

- Rotational sources can now be connected to each other if their speeds have the same direction. Sources with slower speeds will be overpowered by the others.
- Added a skeleton for torque mechanics. Very janky and unfinished
This commit is contained in:
simibubi 2019-11-01 01:09:38 +01:00
parent a1850ec90b
commit 5655fa0609
22 changed files with 501 additions and 71 deletions

View file

@ -4,6 +4,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.simibubi.create.modules.ModuleLoadedCondition;
import com.simibubi.create.modules.contraptions.TorquePropagator;
import com.simibubi.create.modules.contraptions.receivers.constructs.MovingConstructHandler;
import com.simibubi.create.modules.logistics.FrequencyHandler;
import com.simibubi.create.modules.logistics.management.LogisticalNetworkHandler;
@ -42,6 +43,7 @@ public class Create {
public static FrequencyHandler frequencyHandler;
public static MovingConstructHandler constructHandler;
public static LogisticalNetworkHandler logisticalNetworkHandler;
public static TorquePropagator torquePropagator;
public static LogisticianHandler logisticianHandler;
public static ModConfig config;
@ -66,6 +68,7 @@ public class Create {
frequencyHandler = new FrequencyHandler();
constructHandler = new MovingConstructHandler();
logisticalNetworkHandler = new LogisticalNetworkHandler();
torquePropagator = new TorquePropagator();
CraftingHelper.register(new ModuleLoadedCondition.Serializer());
AllPackets.registerPackets();

View file

@ -46,6 +46,7 @@ public class Events {
Create.frequencyHandler.onLoadWorld(world);
Create.constructHandler.onLoadWorld(world);
Create.logisticalNetworkHandler.onLoadWorld(world);
Create.torquePropagator.onLoadWorld(world);
}
@SubscribeEvent
@ -54,6 +55,7 @@ public class Events {
Create.frequencyHandler.onUnloadWorld(world);
Create.constructHandler.onUnloadWorld(world);
Create.logisticalNetworkHandler.onUnloadWorld(world);
Create.torquePropagator.onUnloadWorld(world);
}
@SubscribeEvent

View file

@ -6,8 +6,12 @@ import java.util.Locale;
import com.simibubi.create.Create;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class Lang {
@ -23,6 +27,21 @@ public class Lang {
player.sendStatusMessage(getTranslationComponent(key, args), true);
}
// Deprecated so simi doensn't forget to remove debug calls
@OnlyIn(value = Dist.CLIENT)
@Deprecated
public static void debugChat(String message) {
if (Minecraft.getInstance().player != null)
Minecraft.getInstance().player.sendStatusMessage(new StringTextComponent(message), false);
}
@OnlyIn(value = Dist.CLIENT)
@Deprecated
public static void debugMessage(String message) {
if (Minecraft.getInstance().player != null)
Minecraft.getInstance().player.sendStatusMessage(new StringTextComponent(message), true);
}
public static List<String> translatedOptions(String prefix, String... keys) {
List<String> result = new ArrayList<>(keys.length);
for (String key : keys) {

View file

@ -0,0 +1,118 @@
package com.simibubi.create.modules.contraptions;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
public class KineticNetwork {
public UUID id;
private float stressCapacityPool;
private float maxStress;
private float currentStress;
public boolean initialized;
public Map<KineticTileEntity, Float> sources;
public Set<KineticTileEntity> members;
public KineticNetwork() {
id = UUID.randomUUID();
maxStress = stressCapacityPool = 0;
setCurrentStress(0);
sources = new HashMap<>();
members = new HashSet<>();
}
public void initFromTE(KineticTileEntity te) {
maxStress = stressCapacityPool = te.maxStress;
currentStress = te.currentStress;
initialized = true;
addSilently(te);
}
public void addSilently(KineticTileEntity te) {
if (members.contains(te))
return;
if (te.isSource()) {
float capacity = te.getAddedStressCapacity();
stressCapacityPool -= capacity;
sources.put(te, capacity);
}
members.add(te);
}
public void add(KineticTileEntity te) {
if (members.contains(te))
return;
Lang.debugChat(te.getType().getRegistryName().getPath() + " added to Network");
te.setNetworkID(this.id);
if (te.isSource()) {
float capacity = te.getAddedStressCapacity();
sources.put(te, capacity);
updateMaxStress();
}
members.add(te);
setCurrentStress(getCurrentStress() + te.getStressApplied());
sync();
}
public void updateCapacityFor(KineticTileEntity te, float capacity) {
sources.put(te, capacity);
updateMaxStress();
}
public void remove(KineticTileEntity te) {
if (!members.contains(te))
return;
Lang.debugChat(te.getType().getRegistryName().getPath() + " removed from Network");
if (te.isSource()) {
sources.remove(te);
updateMaxStress();
}
members.remove(te);
setCurrentStress(getCurrentStress() - te.getStressApplied());
sync();
}
public void sync() {
for (KineticTileEntity te : members) {
te.sync(id, getMaxStress(), getCurrentStress());
}
}
public float getMaxStress() {
return maxStress;
}
private void updateMaxStress() {
float presentCapacity = 0;
for (Float cap : sources.values())
presentCapacity += cap;
float newMaxStress = presentCapacity + stressCapacityPool;
if (maxStress != newMaxStress) {
maxStress = newMaxStress;
sync();
}
Lang.debugChat("Current Stress level: " + currentStress + "/" + maxStress);
}
public float getCurrentStress() {
return currentStress;
}
public void setCurrentStress(float currentStress) {
this.currentStress = currentStress;
Lang.debugChat("Current Stress level: " + currentStress + "/" + maxStress);
}
}

View file

@ -173,8 +173,7 @@ public class RotationPropagator {
return;
if (!worldIn.isBlockPresent(pos))
return;
if (addedTE.getSpeed() != 0) {
if (addedTE.speed != 0) {
propagateNewSource(addedTE);
return;
}
@ -182,16 +181,16 @@ public class RotationPropagator {
for (KineticTileEntity neighbourTE : getConnectedNeighbours(addedTE)) {
final float speedModifier = getRotationSpeedModifier(neighbourTE, addedTE);
if (neighbourTE.getSpeed() == 0)
if (neighbourTE.speed == 0)
continue;
if (neighbourTE.hasSource() && neighbourTE.getSource().equals(addedTE.getPos())) {
addedTE.setSpeed(neighbourTE.getSpeed() * speedModifier);
addedTE.setSpeed(neighbourTE.speed * speedModifier);
addedTE.onSpeedChanged();
addedTE.sendData();
continue;
}
addedTE.setSpeed(neighbourTE.getSpeed() * speedModifier);
addedTE.setSpeed(neighbourTE.speed * speedModifier);
addedTE.setSource(neighbourTE.getPos());
addedTE.onSpeedChanged();
addedTE.sendData();
@ -210,18 +209,63 @@ public class RotationPropagator {
World world = updateTE.getWorld();
for (KineticTileEntity neighbourTE : getConnectedNeighbours(updateTE)) {
final float newSpeed = updateTE.getSpeed() * getRotationSpeedModifier(updateTE, neighbourTE);
float modFromTo = getRotationSpeedModifier(updateTE, neighbourTE);
float modToFrom = getRotationSpeedModifier(neighbourTE, updateTE);
final float newSpeed = updateTE.speed * modFromTo;
float oppositeSpeed = neighbourTE.speed * modToFrom;
if ((neighbourTE.isSource())
|| neighbourTE.hasSource() && !neighbourTE.getSource().equals(updateTE.getPos())) {
if (neighbourTE.getSpeed() != newSpeed || Math.abs(newSpeed) > parameters.maxRotationSpeed.get()) {
boolean incompatible = Math.signum(newSpeed) != Math.signum(neighbourTE.speed)
&& (newSpeed != 0 && neighbourTE.speed != 0);
boolean tooFast = Math.abs(newSpeed) > parameters.maxRotationSpeed.get();
if (tooFast) {
world.destroyBlock(pos, true);
return;
}
boolean isSource = neighbourTE.isSource();
boolean hasSource = neighbourTE.hasSource();
boolean poweredBySomethingElse = isSource
|| hasSource && !neighbourTE.getSource().equals(updateTE.getPos());
if (poweredBySomethingElse) {
if (neighbourTE.speed != newSpeed) {
if (incompatible) {
// Opposite directions
world.destroyBlock(pos, true);
return;
} else {
// Same direction: overpower the slower speed
if (Math.abs(oppositeSpeed) > Math.abs(updateTE.speed)) {
// Neighbour faster, overpower the incoming tree
updateTE.setSource(neighbourTE.getPos());
updateTE.setSpeed(neighbourTE.speed * getRotationSpeedModifier(neighbourTE, updateTE));
updateTE.onSpeedChanged();
updateTE.sendData();
propagateNewSource(updateTE);
return;
}
if (Math.abs(newSpeed) > Math.abs(neighbourTE.speed)) {
// Current faster, overpower the neighbours' tree
if (updateTE.hasSource() && updateTE.getSource().equals(neighbourTE.getPos())) {
updateTE.removeSource();
}
neighbourTE.setSource(updateTE.getPos());
neighbourTE.setSpeed(updateTE.speed * getRotationSpeedModifier(updateTE, neighbourTE));
neighbourTE.onSpeedChanged();
neighbourTE.sendData();
propagateNewSource(neighbourTE);
continue;
}
}
}
continue;
}
if (neighbourTE.getSpeed() == newSpeed)
if (neighbourTE.speed == newSpeed)
continue;
neighbourTE.setSpeed(newSpeed);
@ -245,7 +289,7 @@ public class RotationPropagator {
return;
if (removedTE == null)
return;
if (removedTE.getSpeed() == 0)
if (removedTE.speed == 0)
return;
for (BlockPos neighbourPos : getPotentialNeighbourLocations(removedTE)) {
@ -254,7 +298,7 @@ public class RotationPropagator {
continue;
final KineticTileEntity neighbourTE = (KineticTileEntity) worldIn.getTileEntity(neighbourPos);
if (!neighbourTE.hasSource() || !neighbourTE.getSource().equals(pos) || neighbourTE.isSource())
if (!neighbourTE.hasSource() || !neighbourTE.getSource().equals(pos))
continue;
propagateMissingSource(neighbourTE);
@ -283,11 +327,6 @@ public class RotationPropagator {
currentTE.sendData();
for (KineticTileEntity neighbourTE : getConnectedNeighbours(currentTE)) {
if (neighbourTE.isSource()) {
potentialNewSources.add(neighbourTE);
continue;
}
if (!neighbourTE.hasSource())
continue;
@ -296,6 +335,10 @@ public class RotationPropagator {
continue;
}
if (neighbourTE.isSource()) {
potentialNewSources.add(neighbourTE);
}
frontier.add(neighbourTE.getPos());
}
}

View file

@ -0,0 +1,50 @@
package com.simibubi.create.modules.contraptions;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import com.simibubi.create.Create;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.IWorld;
public class TorquePropagator {
static Map<IWorld, Map<UUID, KineticNetwork>> networks = new HashMap<>();
public void onLoadWorld(IWorld world) {
networks.put(world, new HashMap<>());
Create.logger.debug("Prepared Kinetic Network Space for " + world.getDimension().getType().getRegistryName());
}
public void onUnloadWorld(IWorld world) {
networks.remove(world);
Create.logger.debug("Removed Kinetic Network Space for " + world.getDimension().getType().getRegistryName());
}
public KineticNetwork getNetworkFor(KineticTileEntity te) {
UUID id = te.getNetworkID();
KineticNetwork network;
Map<UUID, KineticNetwork> map = networks.get(te.getWorld());
if (id == null) {
network = new KineticNetwork();
//TODO
Minecraft.getInstance().player.sendStatusMessage(new StringTextComponent(te.getType().getRegistryName().getPath() + " created new Network"), false);
map.put(id, network);
} else {
if (!map.containsKey(id)) {
network = new KineticNetwork();
network.id = te.getNetworkID();
map.put(id, network);
}
network = map.get(id);
}
return network;
}
}

View file

@ -2,36 +2,82 @@ package com.simibubi.create.modules.contraptions.base;
import java.util.Optional;
import java.util.Random;
import java.util.UUID;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.block.SyncedTileEntity;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.modules.contraptions.KineticNetwork;
import com.simibubi.create.modules.contraptions.RotationPropagator;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.particles.RedstoneParticleData;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
public abstract class KineticTileEntity extends SyncedTileEntity {
public abstract class KineticTileEntity extends SyncedTileEntity implements ITickableTileEntity {
protected float speed;
protected float force;
public float speed;
protected Optional<BlockPos> source;
public boolean reActivateSource;
public float maxStress;
public float currentStress;
public UUID networkID;
protected boolean overStressed;
protected boolean initNetwork;
public KineticTileEntity(TileEntityType<?> typeIn) {
super(typeIn);
speed = 0;
force = 0;
source = Optional.empty();
}
public void sync(UUID networkID, float maxStress, float currentStress) {
this.setNetworkID(networkID);
this.maxStress = maxStress;
this.currentStress = currentStress;
boolean overStressed = maxStress < currentStress;
if (overStressed != this.overStressed) {
Lang.debugChat(getType().getRegistryName().getPath() + " jammed (" + currentStress + "/" + maxStress + ")");
this.overStressed = overStressed;
sendData();
}
}
public float getAddedStressCapacity() {
return 0;
}
public float getStressApplied() {
return isSource() ? 0 : 1;
}
protected void notifyStressChange(float diff) {
KineticNetwork network = getNetwork();
network.setCurrentStress(network.getCurrentStress() + diff);
network.sync();
}
protected void notifyStressCapacityChange(float capacity) {
getNetwork().updateCapacityFor(this, capacity);
}
@Override
public boolean hasFastRenderer() {
return true;
}
public void onSpeedChanged() {
// if (isSource() && !world.isRemote) {
// if (networkID == null)
// getNetwork().add(this);
// }
}
@Override
@ -40,32 +86,45 @@ public abstract class KineticTileEntity extends SyncedTileEntity {
super.remove();
return;
}
if (hasNetwork()) {
getNetwork().remove(this);
}
RotationPropagator.handleRemoved(getWorld(), getPos(), this);
super.remove();
}
@Override
public CompoundNBT write(CompoundNBT compound) {
compound.putFloat("Speed", getSpeed());
compound.putFloat("Force", getForce());
compound.putFloat("Speed", speed);
if (hasSource())
compound.put("Source", NBTUtil.writeBlockPos(getSource()));
if (hasNetwork()) {
compound.putFloat("MaxStress", maxStress);
compound.putFloat("Stress", currentStress);
compound.put("Id", NBTUtil.writeUniqueId(getNetworkID()));
}
return super.write(compound);
}
@Override
public void read(CompoundNBT compound) {
setSpeed(compound.getFloat("Speed"));
setForce(compound.getFloat("Force"));
setSource(null);
if (compound.contains("Source")) {
CompoundNBT tagSource = compound.getCompound("Source");
setSource(NBTUtil.readBlockPos(tagSource));
}
if (compound.contains("Id")) {
maxStress = compound.getFloat("MaxStress");
currentStress = compound.getFloat("Stress");
overStressed = maxStress < currentStress;
setNetworkID(NBTUtil.readUniqueId(compound.getCompound("Id")));
initNetwork = true;
}
super.read(compound);
}
@ -74,6 +133,8 @@ public abstract class KineticTileEntity extends SyncedTileEntity {
}
public float getSpeed() {
if (overStressed)
return 0;
return speed;
}
@ -90,14 +151,6 @@ public abstract class KineticTileEntity extends SyncedTileEntity {
}
}
public float getForce() {
return force;
}
public void setForce(float force) {
this.force = force;
}
public boolean hasSource() {
return source.isPresent();
}
@ -113,14 +166,49 @@ public abstract class KineticTileEntity extends SyncedTileEntity {
public void setSource(BlockPos source) {
this.source = Optional.ofNullable(source);
if (world == null || world.isRemote)
return;
if (hasNetwork()) {
getNetwork().remove(this);
networkID = null;
}
if (source == null)
return;
KineticTileEntity sourceTe = (KineticTileEntity) world.getTileEntity(source);
if (sourceTe == null)
return;
Create.torquePropagator.getNetworkFor(sourceTe).add(this);
}
public void removeSource() {
if (hasSource() && isSource())
reActivateSource = true;
this.source = Optional.empty();
if (hasNetwork() && !isSource()) {
getNetwork().remove(this);
networkID = null;
}
setSpeed(0);
onSpeedChanged();
}
public KineticNetwork getNetwork() {
KineticNetwork networkFor = Create.torquePropagator.getNetworkFor(this);
if (!networkFor.initialized) {
networkFor.add(this);
networkFor.initialized = true;
}
return networkFor;
}
public boolean hasNetwork() {
return networkID != null;
}
public void applyNewSpeed(float speed) {
detachKinetics();
this.speed = speed;
@ -135,4 +223,38 @@ public abstract class KineticTileEntity extends SyncedTileEntity {
RotationPropagator.handleRemoved(world, pos, this);
}
public UUID getNetworkID() {
return networkID;
}
public void setNetworkID(UUID networkID) {
this.networkID = networkID;
}
/**
* Callback for source blocks to re-apply their speed when an overpowering
* source is removed
*/
public void reActivateSource() {
}
@Override
public void tick() {
if (reActivateSource) {
reActivateSource();
reActivateSource = false;
}
if (initNetwork) {
initNetwork = false;
KineticNetwork network = getNetwork();
if (network.initialized) {
network.addSilently(this);
} else {
network.initFromTE(this);
}
}
}
}

View file

@ -5,10 +5,9 @@ import com.simibubi.create.AllTileEntities;
import com.simibubi.create.CreateConfig;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.util.math.MathHelper;
public class MotorTileEntity extends KineticTileEntity implements ITickableTileEntity {
public class MotorTileEntity extends KineticTileEntity {
public static final int DEFAULT_SPEED = 64;
public int newSpeed;
@ -17,6 +16,12 @@ public class MotorTileEntity extends KineticTileEntity implements ITickableTileE
public MotorTileEntity() {
super(AllTileEntities.MOTOR.type);
setSpeed(DEFAULT_SPEED);
lastModified = -1;
}
@Override
public float getAddedStressCapacity() {
return 500;
}
@Override
@ -35,6 +40,13 @@ public class MotorTileEntity extends KineticTileEntity implements ITickableTileE
newSpeed = (int) speed;
}
@Override
public void removeSource() {
float speed = this.speed;
super.removeSource();
setSpeed(speed);
}
public int getSpeedValue() {
if (world.isRemote)
return newSpeed;
@ -56,6 +68,8 @@ public class MotorTileEntity extends KineticTileEntity implements ITickableTileE
@Override
public void tick() {
super.tick();
if (!world.isRemote)
return;
if (lastModified == -1)

View file

@ -83,7 +83,7 @@ public class WaterWheelBlock extends HorizontalKineticBlock {
flowVec = flowVec.scale(f.getAxisDirection().getOffset());
boolean clockwise = wf.getAxisDirection() == AxisDirection.POSITIVE;
int clockwiseMultiplier = 1; // No difference. Causes confusion
int clockwiseMultiplier = 2;
if (wf.getAxis() == Axis.Z) {
if (f.getAxis() == Axis.Y)
@ -103,6 +103,8 @@ public class WaterWheelBlock extends HorizontalKineticBlock {
}
private void updateWheelSpeed(IWorld world, BlockPos pos) {
if (world.isRemote())
return;
WaterWheelTileEntity te = (WaterWheelTileEntity) world.getTileEntity(pos);
if (te == null)
return;

View file

@ -2,6 +2,7 @@ package com.simibubi.create.modules.contraptions.generators;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.modules.contraptions.RotationPropagator;
@ -53,19 +54,27 @@ public class WaterWheelTileEntity extends KineticTileEntity {
flows.put(direction, speed);
}
@Override
public void reActivateSource() {
updateSpeed();
}
public void updateSpeed() {
float speed = 0;
for (Integer i : flows.values())
speed += i;
if (this.speed != speed) {
hasFlows = speed != 0;
notifyStressCapacityChange(getAddedStressCapacity());
source = Optional.empty();
RotationPropagator.handleRemoved(world, pos, this);
this.setSpeed(speed);
hasFlows = speed != 0;
sendData();
RotationPropagator.handleAdded(world, pos, this);
}
onSpeedChanged();
}
@Override
@ -73,4 +82,12 @@ public class WaterWheelTileEntity extends KineticTileEntity {
return hasFlows;
}
@Override
public float getAddedStressCapacity() {
float torque = 0;
for (Integer i : flows.values())
torque += i;
return Math.abs(torque);
}
}

View file

@ -15,7 +15,6 @@ import net.minecraft.fluid.IFluidState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.AxisAlignedBB;
@ -25,7 +24,7 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameRules;
import net.minecraft.world.server.ServerWorld;
public class DrillTileEntity extends KineticTileEntity implements ITickableTileEntity {
public class DrillTileEntity extends KineticTileEntity {
private static final AtomicInteger NEXT_DRILL_ID = new AtomicInteger();
@ -73,6 +72,8 @@ public class DrillTileEntity extends KineticTileEntity implements ITickableTileE
@Override
public void tick() {
super.tick();
if (world.isRemote)
return;
if (speed == 0)

View file

@ -6,6 +6,7 @@ import static net.minecraft.util.Direction.AxisDirection.NEGATIVE;
import static net.minecraft.util.Direction.AxisDirection.POSITIVE;
import java.util.List;
import java.util.Optional;
import com.simibubi.create.AllBlockTags;
import com.simibubi.create.AllBlocks;
@ -24,7 +25,6 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Direction;
import net.minecraft.util.SoundCategory;
@ -35,7 +35,7 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
public class EncasedFanTileEntity extends KineticTileEntity implements ITickableTileEntity {
public class EncasedFanTileEntity extends KineticTileEntity {
private static DamageSource damageSourceFire = new DamageSource("create.fan_fire").setDifficultyScaled()
.setFireDamage();
@ -91,14 +91,23 @@ public class EncasedFanTileEntity extends KineticTileEntity implements ITickable
return isGenerator;
}
@Override
public float getAddedStressCapacity() {
return 50;
}
public void updateGenerator() {
boolean shouldGenerate = world.isBlockPowered(pos) && world.isBlockPresent(pos.down()) && blockBelowIsHot();
if (shouldGenerate == isGenerator)
return;
isGenerator = shouldGenerate;
if (isGenerator)
if (isGenerator) {
notifyStressCapacityChange(getAddedStressCapacity());
removeSource();
} else {
notifyStressCapacityChange(0);
}
applyNewSpeed(isGenerator ? CreateConfig.parameters.generatingFanSpeed.get() : 0);
sendData();
}
@ -182,8 +191,16 @@ public class EncasedFanTileEntity extends KineticTileEntity implements ITickable
updateFrontBlock();
}
@Override
public void reActivateSource() {
source = Optional.empty();
applyNewSpeed(isGenerator ? CreateConfig.parameters.generatingFanSpeed.get() : 0);
}
@Override
public void tick() {
super.tick();
if (speed == 0 || isGenerator)
return;

View file

@ -22,7 +22,6 @@ import net.minecraft.item.crafting.ShapelessRecipe;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.particles.ItemParticleData;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.NonNullList;
@ -35,7 +34,7 @@ import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemHandlerHelper;
public class MechanicalMixerTileEntity extends KineticTileEntity implements ITickableTileEntity {
public class MechanicalMixerTileEntity extends KineticTileEntity {
public int runningTicks;
public int processingTicks;
@ -132,6 +131,7 @@ public class MechanicalMixerTileEntity extends KineticTileEntity implements ITic
@Override
public void tick() {
super.tick();
if (world.isRemote && lastModified != -1) {
if (lastModified++ > 10) {

View file

@ -13,7 +13,6 @@ import net.minecraft.entity.item.ItemEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.particles.ItemParticleData;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.AxisAlignedBB;
@ -22,7 +21,7 @@ import net.minecraft.util.math.Vec3d;
import net.minecraftforge.items.ItemStackHandler;
import net.minecraftforge.items.wrapper.RecipeWrapper;
public class MechanicalPressTileEntity extends KineticTileEntity implements ITickableTileEntity {
public class MechanicalPressTileEntity extends KineticTileEntity {
public static class PressingInv extends RecipeWrapper {
public PressingInv() {
@ -85,6 +84,8 @@ public class MechanicalPressTileEntity extends KineticTileEntity implements ITic
@Override
public void tick() {
super.tick();
if (!running)
return;

View file

@ -1,5 +1,7 @@
package com.simibubi.create.modules.contraptions.receivers.constructs;
import java.util.Optional;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.modules.contraptions.RotationPropagator;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
@ -8,7 +10,6 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.AxisAlignedBB;
@ -18,7 +19,7 @@ import net.minecraft.world.gen.feature.template.Template.BlockInfo;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class MechanicalBearingTileEntity extends KineticTileEntity implements ITickableTileEntity {
public class MechanicalBearingTileEntity extends KineticTileEntity {
protected RotationConstruct movingConstruct;
protected float angle;
@ -42,6 +43,11 @@ public class MechanicalBearingTileEntity extends KineticTileEntity implements IT
return super.getMaxRenderDistanceSquared() * 16;
}
@Override
public float getAddedStressCapacity() {
return getWindmillSpeed() * 50;
}
@Override
public boolean isSource() {
return isWindmill;
@ -144,10 +150,16 @@ public class MechanicalBearingTileEntity extends KineticTileEntity implements IT
getWorld().setBlockState(info.pos.add(pos), Blocks.AIR.getDefaultState(), 67);
}
applyWindmillSpeed();
}
public void applyWindmillSpeed() {
if (isWindmill) {
RotationPropagator.handleRemoved(world, pos, this);
source = Optional.empty();
speed = getWindmillSpeed();
RotationPropagator.handleAdded(world, pos, this);
sendData();
}
}
@ -177,8 +189,15 @@ public class MechanicalBearingTileEntity extends KineticTileEntity implements IT
sendData();
}
@Override
public void reActivateSource() {
applyWindmillSpeed();
}
@Override
public void tick() {
super.tick();
if (running && RotationConstruct.isFrozen())
disassembleConstruct();

View file

@ -19,7 +19,6 @@ import com.simibubi.create.modules.contraptions.receivers.constructs.MechanicalP
import net.minecraft.block.Blocks;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.AxisAlignedBB;
@ -30,7 +29,7 @@ import net.minecraft.world.gen.feature.template.Template.BlockInfo;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class MechanicalPistonTileEntity extends KineticTileEntity implements ITickableTileEntity {
public class MechanicalPistonTileEntity extends KineticTileEntity {
protected PistonContraption movedContraption;
protected float offset;
@ -189,6 +188,8 @@ public class MechanicalPistonTileEntity extends KineticTileEntity implements ITi
@Override
public void tick() {
super.tick();
if (!world.isRemote && assembleNextTick) {
assembleNextTick = false;
if (running) {

View file

@ -33,7 +33,7 @@ public class GearboxTileEntityRenderer extends KineticTileEntityRenderer {
float offset = getRotationOffsetForPosition(te, pos, axis);
float angle = (time * te.getSpeed()) % 360;
if (te.getSpeed() != 0) {
if (te.getSpeed() != 0 && te.hasSource()) {
BlockPos source = te.getSource().subtract(te.getPos());
Direction sourceFacing = Direction.getFacingFromVector(source.getX(), source.getY(), source.getZ());
if (sourceFacing.getAxis() == direction.getAxis())

View file

@ -183,7 +183,7 @@ public class BeltItem extends Item {
float speed1 = ((KineticTileEntity) world.getTileEntity(first)).getSpeed();
float speed2 = ((KineticTileEntity) world.getTileEntity(second)).getSpeed();
if (speed1 != speed2 && speed1 != 0 && speed2 != 0)
if (Math.signum(speed1) != Math.signum(speed2) && speed1 != 0 && speed2 != 0)
return false;
BlockPos step = new BlockPos(Math.signum(diff.getX()), Math.signum(diff.getY()), Math.signum(diff.getZ()));

View file

@ -26,7 +26,6 @@ import net.minecraft.nbt.NBTUtil;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
@ -36,7 +35,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
public class BeltTileEntity extends KineticTileEntity implements ITickableTileEntity {
public class BeltTileEntity extends KineticTileEntity {
protected BlockPos controller;
public Map<Entity, TransportedEntityInfo> passengers;
@ -140,6 +139,8 @@ public class BeltTileEntity extends KineticTileEntity implements ITickableTileEn
@Override
public void tick() {
super.tick();
if (world != null && trackerUpdateTag != null) {
attachmentTracker.readAndSearch(trackerUpdateTag, this);
trackerUpdateTag = null;

View file

@ -50,12 +50,12 @@ public class FrequencyHandler {
public void onLoadWorld(IWorld world) {
connections.put(world, new HashMap<>());
Create.logger.debug("Prepared Network Space for " + world.getDimension().getType().getRegistryName());
Create.logger.debug("Prepared Redstone Network Space for " + world.getDimension().getType().getRegistryName());
}
public void onUnloadWorld(IWorld world) {
connections.remove(world);
Create.logger.debug("Removed Network Space for " + world.getDimension().getType().getRegistryName());
Create.logger.debug("Removed Redstone Network Space for " + world.getDimension().getType().getRegistryName());
}
private static Pair<Frequency, Frequency> getNetworkKey(IHaveWireless actor) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B