Fix More Stuff
All checks were successful
EnergonRelics/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-07-26 18:31:05 -04:00
parent 6d92651623
commit 891f2c2fa8
9 changed files with 35 additions and 28 deletions

View File

@ -1,14 +1,10 @@
package com.thebrokenrail.energonrelics.block.entity; package com.thebrokenrail.energonrelics.block.entity;
import com.thebrokenrail.energonrelics.config.HardcodedConfig; import com.thebrokenrail.energonrelics.energy.core.util.EnergyTickable;
import com.thebrokenrail.energonrelics.energy.core.EnergyProviderBlockEntity;
import com.thebrokenrail.energonrelics.energy.helper.EnergyGeneratorBlockEntity; import com.thebrokenrail.energonrelics.energy.helper.EnergyGeneratorBlockEntity;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.util.math.Direction;
import net.minecraft.world.LightType;
import java.util.List; import java.util.List;
import java.util.Objects;
public class CreativeEnergySourceBlockEntity extends EnergyGeneratorBlockEntity { public class CreativeEnergySourceBlockEntity extends EnergyGeneratorBlockEntity {
public CreativeEnergySourceBlockEntity(BlockEntityType<?> type) { public CreativeEnergySourceBlockEntity(BlockEntityType<?> type) {
@ -21,7 +17,7 @@ public class CreativeEnergySourceBlockEntity extends EnergyGeneratorBlockEntity
} }
@Override @Override
public List<EnergyProviderBlockEntity> startTick() { public List<EnergyTickable> startTick() {
setEnergy(getDisplayEnergy()); setEnergy(getDisplayEnergy());
return super.startTick(); return super.startTick();
} }

View File

@ -3,6 +3,7 @@ package com.thebrokenrail.energonrelics.block.entity;
import com.thebrokenrail.energonrelics.config.HardcodedConfig; import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import com.thebrokenrail.energonrelics.energy.core.EnergyProviderBlockEntity; import com.thebrokenrail.energonrelics.energy.core.EnergyProviderBlockEntity;
import com.thebrokenrail.energonrelics.energy.core.util.Action; import com.thebrokenrail.energonrelics.energy.core.util.Action;
import com.thebrokenrail.energonrelics.energy.core.util.EnergyTickable;
import com.thebrokenrail.energonrelics.energy.helper.EnergyGenerator; import com.thebrokenrail.energonrelics.energy.helper.EnergyGenerator;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
@ -50,7 +51,7 @@ public class LightningRodBlockEntity extends EnergyProviderBlockEntity implement
} }
@Override @Override
public List<EnergyProviderBlockEntity> startTick() { public List<EnergyTickable> startTick() {
if (cooldown <= 0) { if (cooldown <= 0) {
energy = 0; energy = 0;

View File

@ -2,6 +2,7 @@ package com.thebrokenrail.energonrelics.block.entity;
import com.thebrokenrail.energonrelics.config.HardcodedConfig; import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import com.thebrokenrail.energonrelics.energy.core.EnergyProviderBlockEntity; import com.thebrokenrail.energonrelics.energy.core.EnergyProviderBlockEntity;
import com.thebrokenrail.energonrelics.energy.core.util.EnergyTickable;
import com.thebrokenrail.energonrelics.energy.helper.EnergyGeneratorBlockEntity; import com.thebrokenrail.energonrelics.energy.helper.EnergyGeneratorBlockEntity;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
@ -39,7 +40,7 @@ public class SolarPanelBlockEntity extends EnergyGeneratorBlockEntity {
} }
@Override @Override
public List<EnergyProviderBlockEntity> startTick() { public List<EnergyTickable> startTick() {
setEnergy(getDisplayEnergy()); setEnergy(getDisplayEnergy());
return super.startTick(); return super.startTick();
} }

View File

@ -6,6 +6,7 @@ import com.thebrokenrail.energonrelics.block.battery.PassiveBatteryControllerBlo
import com.thebrokenrail.energonrelics.block.entity.battery.PassiveBatteryControllerBlockEntity; import com.thebrokenrail.energonrelics.block.entity.battery.PassiveBatteryControllerBlockEntity;
import com.thebrokenrail.energonrelics.block.reactor.ReactorControllerBlock; import com.thebrokenrail.energonrelics.block.reactor.ReactorControllerBlock;
import com.thebrokenrail.energonrelics.energy.core.EnergyProviderBlockEntity; import com.thebrokenrail.energonrelics.energy.core.EnergyProviderBlockEntity;
import com.thebrokenrail.energonrelics.energy.core.util.EnergyTickable;
import com.thebrokenrail.energonrelics.energy.helper.EnergyGeneratorBlockEntity; import com.thebrokenrail.energonrelics.energy.helper.EnergyGeneratorBlockEntity;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
@ -33,7 +34,7 @@ public class ReactorControllerBlockEntity extends EnergyGeneratorBlockEntity {
} }
@Override @Override
public List<EnergyProviderBlockEntity> startTick() { public List<EnergyTickable> startTick() {
if (getCachedState().get(ReactorControllerBlock.POWERED)) { if (getCachedState().get(ReactorControllerBlock.POWERED)) {
Reactor reactor = getReactor(); Reactor reactor = getReactor();
if (reactor != null && !reactor.core.isReacting()) { if (reactor != null && !reactor.core.isReacting()) {

View File

@ -4,6 +4,7 @@ import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import com.thebrokenrail.energonrelics.EnergonRelics; import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.component.NetworkComponent; import com.thebrokenrail.energonrelics.component.NetworkComponent;
import com.thebrokenrail.energonrelics.energy.core.util.Action; import com.thebrokenrail.energonrelics.energy.core.util.Action;
import com.thebrokenrail.energonrelics.energy.core.util.EnergyTickable;
import com.thebrokenrail.energonrelics.energy.core.util.EnergyTicker; import com.thebrokenrail.energonrelics.energy.core.util.EnergyTicker;
import com.thebrokenrail.energonrelics.util.BlockPosWithDimension; import com.thebrokenrail.energonrelics.util.BlockPosWithDimension;
import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable; import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
@ -24,7 +25,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
public class EnergyProviderBlockEntity extends BlockEntity implements BlockEntityClientSerializable, Tickable { public class EnergyProviderBlockEntity extends BlockEntity implements BlockEntityClientSerializable, Tickable, EnergyTickable {
public EnergyProviderBlockEntity(BlockEntityType<?> type) { public EnergyProviderBlockEntity(BlockEntityType<?> type) {
super(type); super(type);
} }
@ -80,10 +81,12 @@ public class EnergyProviderBlockEntity extends BlockEntity implements BlockEntit
} }
} }
@Override
public void logicTick() { public void logicTick() {
} }
public List<EnergyProviderBlockEntity> startTick() { @Override
public List<EnergyTickable> startTick() {
if (isEnergyProvider()) { if (isEnergyProvider()) {
NetworkComponent component = NetworkComponent.getInstance((ServerWorld) Objects.requireNonNull(getWorld())); NetworkComponent component = NetworkComponent.getInstance((ServerWorld) Objects.requireNonNull(getWorld()));
List<BlockPosWithDimension> sources = component.getSourcePos(EnergonRelics.NETWORK_CHIP_ITEM.getID(stack)); List<BlockPosWithDimension> sources = component.getSourcePos(EnergonRelics.NETWORK_CHIP_ITEM.getID(stack));

View File

@ -2,6 +2,7 @@ package com.thebrokenrail.energonrelics.energy.core;
import com.thebrokenrail.energonrelics.component.NetworkComponent; import com.thebrokenrail.energonrelics.component.NetworkComponent;
import com.thebrokenrail.energonrelics.energy.core.util.Action; import com.thebrokenrail.energonrelics.energy.core.util.Action;
import com.thebrokenrail.energonrelics.energy.core.util.EnergyTickable;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
@ -46,10 +47,10 @@ public abstract class EnergyReceiverBlockEntity extends EnergyProviderBlockEntit
} }
@Override @Override
public List<EnergyProviderBlockEntity> startTick() { public List<EnergyTickable> startTick() {
sent.clear(); sent.clear();
List<EnergyProviderBlockEntity> list = new ArrayList<>(super.startTick()); List<EnergyTickable> list = new ArrayList<>(super.startTick());
ServerWorld world = (ServerWorld) getWorld(); ServerWorld world = (ServerWorld) getWorld();
assert world != null; assert world != null;

View File

@ -0,0 +1,8 @@
package com.thebrokenrail.energonrelics.energy.core.util;
import java.util.List;
public interface EnergyTickable {
List<EnergyTickable> startTick();
void logicTick();
}

View File

@ -1,6 +1,5 @@
package com.thebrokenrail.energonrelics.energy.core.util; package com.thebrokenrail.energonrelics.energy.core.util;
import com.thebrokenrail.energonrelics.energy.core.EnergyProviderBlockEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.ArrayList; import java.util.ArrayList;
@ -9,22 +8,20 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
public class EnergyTicker { public class EnergyTicker {
private static final List<EnergyProviderBlockEntity> scheduled = new ArrayList<>(); private static final List<EnergyTickable> scheduled = new ArrayList<>();
public static void schedule(EnergyProviderBlockEntity provider) { public static void schedule(EnergyTickable tickable) {
scheduled.add(provider); scheduled.add(tickable);
} }
public static void tick(World world) { public static void tick(World world) {
if (Objects.requireNonNull(world.getServer()).getThread() != Thread.currentThread()) { if (Objects.requireNonNull(world.getServer()).getThread() == Thread.currentThread()) {
scheduled.clear(); List<EnergyTickable> started = new ArrayList<>();
} else {
List<EnergyProviderBlockEntity> started = new ArrayList<>();
List<EnergyProviderBlockEntity> temp = new ArrayList<>(scheduled); List<EnergyTickable> temp = new ArrayList<>(scheduled);
List<EnergyProviderBlockEntity> temp2 = new ArrayList<>(); List<EnergyTickable> temp2 = new ArrayList<>();
while (!temp.isEmpty()) { while (!temp.isEmpty()) {
for (EnergyProviderBlockEntity provider : temp) { for (EnergyTickable provider : temp) {
if (!started.contains(provider)) { if (!started.contains(provider)) {
temp2.addAll(provider.startTick()); temp2.addAll(provider.startTick());
started.add(provider); started.add(provider);
@ -36,11 +33,10 @@ public class EnergyTicker {
} }
Collections.shuffle(started); Collections.shuffle(started);
for (EnergyProviderBlockEntity provider : started) { for (EnergyTickable provider : started) {
provider.logicTick(); provider.logicTick();
} }
}
scheduled.clear(); scheduled.clear();
} }
} }
}

View File

@ -1,3 +1,3 @@
{ {
"parent": "energonrelics:holographic_sky_off" "parent": "energonrelics:block/holographic_sky_off"
} }