Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState
if (!pState.is(pNewState.getBlock())) { // new block
MetaMachine machine = MetaMachine.getMachine(pLevel, pPos);
if (machine != null) {
machine.onRemoved();
machine.onMachineDestroyed();
}

pLevel.updateNeighbourForOutputSignal(pPos, this);
Expand Down
12 changes: 1 addition & 11 deletions src/main/java/com/gregtechceu/gtceu/api/capability/IMiner.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
package com.gregtechceu.gtceu.api.capability;

import com.gregtechceu.gtceu.api.machine.feature.IMachineLife;
import com.gregtechceu.gtceu.api.machine.feature.IRecipeLogicMachine;
import com.gregtechceu.gtceu.common.machine.trait.miner.MinerLogic;

public interface IMiner extends IRecipeLogicMachine, IMachineLife {

@Override
MinerLogic getRecipeLogic();

@Override
default void onMachineRemoved() {
getRecipeLogic().onRemove();
}
public interface IMiner extends IRecipeLogicMachine {

boolean drainInput(boolean simulate);

Expand Down
55 changes: 27 additions & 28 deletions src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,26 +157,6 @@ public MetaMachine(BlockEntityCreationInfo info) {
// ***** Machine Lifecycle ******//
//////////////////////////////////////

public void onMachinePlaced(@Nullable LivingEntity player, ItemStack stack) {
if (player instanceof ServerPlayer sPlayer) {
ownerUUID = sPlayer.getUUID();
}

if (this instanceof IDropSaveMachine dropSaveMachine) {
CompoundTag tag = stack.getTag();
if (tag != null) {
dropSaveMachine.loadFromItem(tag);
}
}
}

public void onRemoved() {
for (Direction direction : GTUtil.DIRECTIONS) {
getCoverContainer().removeCover(direction, null);
}
if (this instanceof IMachineLife l) l.onMachineRemoved();
}

@Override
public void load(CompoundTag tag) {
TagCompatibilityFixer.fixMachineAutoOutputTag(tag);
Expand All @@ -196,14 +176,6 @@ public void onLoad() {
}
}

public void setRenderState(MachineRenderState renderState) {
this.renderState = renderState;
if (level != null && !level.isClientSide) {
syncDataHolder.markClientSyncFieldDirty("renderState");
}
scheduleRenderUpdate();
}

@Override
public final void setRemoved() {
super.setRemoved();
Expand All @@ -220,6 +192,25 @@ public void onUnload() {
serverTicks.clear();
}

public void onMachinePlaced(@Nullable LivingEntity player, ItemStack stack) {
if (player instanceof ServerPlayer sPlayer) {
ownerUUID = sPlayer.getUUID();
}

if (this instanceof IDropSaveMachine dropSaveMachine) {
CompoundTag tag = stack.getTag();
if (tag != null) {
dropSaveMachine.loadFromItem(tag);
}
}
}

public void onMachineDestroyed() {
for (Direction direction : GTUtil.DIRECTIONS) {
getCoverContainer().removeCover(direction, null);
}
}

//////////////////////////////////////
// ***** Tickable Manager ****//
//////////////////////////////////////
Expand Down Expand Up @@ -440,6 +431,14 @@ public boolean triggerEvent(int id, int para) {
return false;
}

public void setRenderState(MachineRenderState renderState) {
this.renderState = renderState;
if (level != null && !level.isClientSide) {
syncDataHolder.markClientSyncFieldDirty("renderState");
}
scheduleRenderUpdate();
}

public void setPaintingColor(int color) {
if (color == this.paintingColor) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ protected void chargeBattery() {
// ********** MISC ***********//
//////////////////////////////////////
@Override
public void onMachineRemoved() {
super.onMachineRemoved();
public void onMachineDestroyed() {
super.onMachineDestroyed();
clearInventory(chargerInventory);
if (!ConfigHolder.INSTANCE.machines.ghostCircuit) {
clearInventory(circuitInventory.storage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public abstract class WorkableTieredMachine extends TieredEnergyMachine implements IRecipeLogicMachine,
IMachineLife, IMufflableMachine, IOverclockMachine {
IMufflableMachine, IOverclockMachine {

@Getter
@SaveField
Expand Down Expand Up @@ -144,7 +144,8 @@ public void onUnload() {
//////////////////////////////////////

@Override
public void onMachineRemoved() {
public void onMachineDestroyed() {
super.onMachineDestroyed();
clearInventory(importItems.storage);
clearInventory(exportItems.storage);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public void onLoad() {
}

@Override
public void onMachineRemoved() {
public void onMachineDestroyed() {
super.onMachineDestroyed();
clearInventory(importItems.storage);
clearInventory(exportItems.storage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability;
import com.gregtechceu.gtceu.api.gui.GuiTextures;
import com.gregtechceu.gtceu.api.item.tool.GTToolType;
import com.gregtechceu.gtceu.api.machine.feature.IMachineLife;
import com.gregtechceu.gtceu.api.machine.feature.IMufflableMachine;
import com.gregtechceu.gtceu.api.machine.feature.IRecipeLogicMachine;
import com.gregtechceu.gtceu.api.machine.trait.*;
Expand Down Expand Up @@ -42,7 +41,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public abstract class SteamWorkableMachine extends SteamMachine
implements IRecipeLogicMachine, IMufflableMachine, IMachineLife {
implements IRecipeLogicMachine, IMufflableMachine {

@Getter
protected final CleanroomReceiverTrait cleanroomReceiver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.gregtechceu.gtceu.api.gui.widget.SlotWidget;
import com.gregtechceu.gtceu.api.machine.TieredEnergyMachine;
import com.gregtechceu.gtceu.api.machine.feature.IFancyUIMachine;
import com.gregtechceu.gtceu.api.machine.feature.IMachineLife;
import com.gregtechceu.gtceu.api.machine.trait.NotifiableEnergyContainer;
import com.gregtechceu.gtceu.api.sync_system.annotations.SaveField;
import com.gregtechceu.gtceu.api.transfer.item.CustomItemStackHandler;
Expand Down Expand Up @@ -40,7 +39,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class BatteryBufferMachine extends TieredEnergyMachine
implements IControllable, IFancyUIMachine, IMachineLife, IMonitorComponent {
implements IControllable, IFancyUIMachine, IMonitorComponent {

public static final long AMPS_PER_BATTERY = 2L;

Expand Down Expand Up @@ -191,7 +190,8 @@ private List<Object> getAllBatteries() {
}

@Override
public void onMachineRemoved() {
public void onMachineDestroyed() {
super.onMachineDestroyed();
clearInventory(batteryInventory);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.gregtechceu.gtceu.api.machine.TickableSubscription;
import com.gregtechceu.gtceu.api.machine.TieredEnergyMachine;
import com.gregtechceu.gtceu.api.machine.feature.IFancyUIMachine;
import com.gregtechceu.gtceu.api.machine.feature.IMachineLife;
import com.gregtechceu.gtceu.api.machine.trait.AutoOutputTrait;
import com.gregtechceu.gtceu.api.machine.trait.NotifiableItemStackHandler;
import com.gregtechceu.gtceu.api.sync_system.annotations.SaveField;
Expand Down Expand Up @@ -49,7 +48,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class BlockBreakerMachine extends TieredEnergyMachine
implements IFancyUIMachine, IMachineLife, IControllable {
implements IFancyUIMachine, IControllable {

@SaveField
protected final NotifiableItemStackHandler cache;
Expand Down Expand Up @@ -138,7 +137,8 @@ public void onUnload() {
}

@Override
public void onMachineRemoved() {
public void onMachineDestroyed() {
super.onMachineDestroyed();
clearInventory(chargerInventory);
clearInventory(cache.storage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.gregtechceu.gtceu.api.gui.widget.SlotWidget;
import com.gregtechceu.gtceu.api.machine.TieredEnergyMachine;
import com.gregtechceu.gtceu.api.machine.feature.IFancyUIMachine;
import com.gregtechceu.gtceu.api.machine.feature.IMachineLife;
import com.gregtechceu.gtceu.api.machine.property.GTMachineModelProperties;
import com.gregtechceu.gtceu.api.machine.trait.NotifiableEnergyContainer;
import com.gregtechceu.gtceu.api.sync_system.annotations.RerenderOnChanged;
Expand Down Expand Up @@ -40,7 +39,7 @@

@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class ChargerMachine extends TieredEnergyMachine implements IControllable, IFancyUIMachine, IMachineLife {
public class ChargerMachine extends TieredEnergyMachine implements IControllable, IFancyUIMachine {

public static final long AMPS_PER_ITEM = 4L;

Expand Down Expand Up @@ -111,7 +110,8 @@ public int tintColor(int index) {
}

@Override
public void onMachineRemoved() {
public void onMachineDestroyed() {
super.onMachineDestroyed();
clearInventory(chargerInventory);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.gregtechceu.gtceu.api.machine.TickableSubscription;
import com.gregtechceu.gtceu.api.machine.TieredEnergyMachine;
import com.gregtechceu.gtceu.api.machine.feature.IFancyUIMachine;
import com.gregtechceu.gtceu.api.machine.feature.IMachineLife;
import com.gregtechceu.gtceu.api.machine.trait.AutoOutputTrait;
import com.gregtechceu.gtceu.api.machine.trait.NotifiableItemStackHandler;
import com.gregtechceu.gtceu.api.sync_system.annotations.SaveField;
Expand Down Expand Up @@ -58,7 +57,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class FisherMachine extends TieredEnergyMachine
implements IFancyUIMachine, IMachineLife, IWorkable {
implements IFancyUIMachine, IWorkable {

@SaveField
protected final NotifiableItemStackHandler cache;
Expand Down Expand Up @@ -167,7 +166,8 @@ public boolean shouldWeatherOrTerrainExplosion() {
}

@Override
public void onMachineRemoved() {
public void onMachineDestroyed() {
super.onMachineDestroyed();
clearInventory(chargerInventory);
clearInventory(baitHandler.storage);
clearInventory(cache.storage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.gregtechceu.gtceu.api.machine.TickableSubscription;
import com.gregtechceu.gtceu.api.machine.TieredEnergyMachine;
import com.gregtechceu.gtceu.api.machine.feature.IFancyUIMachine;
import com.gregtechceu.gtceu.api.machine.feature.IMachineLife;
import com.gregtechceu.gtceu.api.machine.property.GTMachineModelProperties;
import com.gregtechceu.gtceu.api.machine.trait.AutoOutputTrait;
import com.gregtechceu.gtceu.api.machine.trait.NotifiableItemStackHandler;
Expand Down Expand Up @@ -56,7 +55,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class ItemCollectorMachine extends TieredEnergyMachine
implements IFancyUIMachine, IMachineLife, IWorkable {
implements IFancyUIMachine, IWorkable {

@Getter
private static final int[] INVENTORY_SIZES = { 4, 9, 16, 25, 25 };
Expand Down Expand Up @@ -173,7 +172,8 @@ public boolean shouldWeatherOrTerrainExplosion() {
}

@Override
public void onMachineRemoved() {
public void onMachineDestroyed() {
super.onMachineDestroyed();
clearInventory(chargerInventory);
clearInventory(output.storage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class MinerMachine extends WorkableTieredMachine
implements IMiner, IControllable, IFancyUIMachine, IDataInfoProvider {
implements IControllable, IFancyUIMachine, IDataInfoProvider, IMiner {

@Getter
@SaveField
Expand Down Expand Up @@ -95,7 +95,7 @@ protected CustomItemStackHandler createChargerItemHandler() {
}

@Override
public void onMachineRemoved() {
public void onMachineDestroyed() {
Comment thread
gustovafing marked this conversation as resolved.
// Remove the miner pipes below this miner
getRecipeLogic().onRemove();
clearInventory(exportItems.storage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.gregtechceu.gtceu.api.gui.widget.TankWidget;
import com.gregtechceu.gtceu.api.gui.widget.ToggleButtonWidget;
import com.gregtechceu.gtceu.api.machine.TieredEnergyMachine;
import com.gregtechceu.gtceu.api.machine.feature.IMachineLife;
import com.gregtechceu.gtceu.api.machine.feature.IUIMachine;
import com.gregtechceu.gtceu.api.machine.trait.AutoOutputTrait;
import com.gregtechceu.gtceu.api.machine.trait.NotifiableFluidTank;
Expand Down Expand Up @@ -54,7 +53,7 @@

@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class PumpMachine extends TieredEnergyMachine implements IUIMachine, IMachineLife {
public class PumpMachine extends TieredEnergyMachine implements IUIMachine {

public static final int BASE_PUMP_RADIUS = 16;
public static final int EXTRA_PUMP_RADIUS = 4;
Expand Down Expand Up @@ -378,7 +377,8 @@ private boolean canAdvancePumpHead() {
}

@Override
public void onMachineRemoved() {
public void onMachineDestroyed() {
super.onMachineDestroyed();
if (getLevel() instanceof ServerLevel serverLevel) {
var pos = getBlockPos().relative(Direction.DOWN);
while (serverLevel.getBlockState(pos).is(GTBlocks.MINER_PIPE.get())) {
Expand Down
Loading
Loading