优化mle1934,调整充电站
This commit is contained in:
parent
67c71bba45
commit
e753990f75
3 changed files with 6 additions and 16 deletions
|
@ -96,13 +96,13 @@ public class ChargingStationBlockEntity extends BlockEntity implements WorldlyCo
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void serverTick(Level pLevel, BlockPos pPos, BlockState pState, ChargingStationBlockEntity blockEntity) {
|
public static void serverTick(Level pLevel, BlockPos pPos, BlockState pState, ChargingStationBlockEntity blockEntity) {
|
||||||
|
blockEntity.setChanged();
|
||||||
if (blockEntity.fuelTick > 0) {
|
if (blockEntity.fuelTick > 0) {
|
||||||
blockEntity.fuelTick--;
|
blockEntity.fuelTick--;
|
||||||
blockEntity.energyHandler.ifPresent(handler -> {
|
blockEntity.energyHandler.ifPresent(handler -> {
|
||||||
int energy = handler.getEnergyStored();
|
int energy = handler.getEnergyStored();
|
||||||
if (energy < handler.getMaxEnergyStored()) {
|
if (energy < handler.getMaxEnergyStored()) {
|
||||||
handler.receiveEnergy(CHARGE_SPEED, false);
|
handler.receiveEnergy(CHARGE_SPEED, false);
|
||||||
blockEntity.setChanged();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -122,7 +122,6 @@ public class ChargingStationBlockEntity extends BlockEntity implements WorldlyCo
|
||||||
blockEntity.fuelTick = burnTime;
|
blockEntity.fuelTick = burnTime;
|
||||||
blockEntity.maxFuelTick = burnTime;
|
blockEntity.maxFuelTick = burnTime;
|
||||||
fuel.shrink(1);
|
fuel.shrink(1);
|
||||||
blockEntity.setChanged();
|
|
||||||
} else if (fuel.getItem().isEdible()) {
|
} else if (fuel.getItem().isEdible()) {
|
||||||
var properties = fuel.getFoodProperties(null);
|
var properties = fuel.getFoodProperties(null);
|
||||||
if (properties == null) return;
|
if (properties == null) return;
|
||||||
|
@ -139,7 +138,6 @@ public class ChargingStationBlockEntity extends BlockEntity implements WorldlyCo
|
||||||
|
|
||||||
blockEntity.fuelTick = tick;
|
blockEntity.fuelTick = tick;
|
||||||
blockEntity.maxFuelTick = tick;
|
blockEntity.maxFuelTick = tick;
|
||||||
blockEntity.setChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,12 +158,11 @@ public class ChargingStationBlockEntity extends BlockEntity implements WorldlyCo
|
||||||
|
|
||||||
List<Entity> entities = this.level.getEntitiesOfClass(Entity.class, new AABB(this.getBlockPos()).inflate(CHARGE_RADIUS));
|
List<Entity> entities = this.level.getEntitiesOfClass(Entity.class, new AABB(this.getBlockPos()).inflate(CHARGE_RADIUS));
|
||||||
entities.forEach(entity -> {
|
entities.forEach(entity -> {
|
||||||
if (entity instanceof IChargeEntity chargeEntity) {
|
if (entity instanceof IChargeEntity chargeEntity && handler.getEnergyStored() > 0) {
|
||||||
chargeEntity.charge(Math.min(CHARGE_OTHER_SPEED, handler.getEnergyStored()));
|
chargeEntity.charge(Math.min(CHARGE_OTHER_SPEED, handler.getEnergyStored()));
|
||||||
handler.extractEnergy(Math.min(CHARGE_OTHER_SPEED, handler.getEnergyStored()), false);
|
handler.extractEnergy(Math.min(CHARGE_OTHER_SPEED, handler.getEnergyStored()), false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.setChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void chargeItemStack(EnergyStorage handler) {
|
private void chargeItemStack(EnergyStorage handler) {
|
||||||
|
@ -176,7 +173,6 @@ public class ChargingStationBlockEntity extends BlockEntity implements WorldlyCo
|
||||||
if (consumer.getEnergyStored() < consumer.getMaxEnergyStored()) {
|
if (consumer.getEnergyStored() < consumer.getMaxEnergyStored()) {
|
||||||
consumer.receiveEnergy(Math.min(CHARGE_OTHER_SPEED, handler.getEnergyStored()), false);
|
consumer.receiveEnergy(Math.min(CHARGE_OTHER_SPEED, handler.getEnergyStored()), false);
|
||||||
handler.extractEnergy(Math.min(CHARGE_OTHER_SPEED, handler.getEnergyStored()), false);
|
handler.extractEnergy(Math.min(CHARGE_OTHER_SPEED, handler.getEnergyStored()), false);
|
||||||
this.setChanged();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -258,16 +254,10 @@ public class ChargingStationBlockEntity extends BlockEntity implements WorldlyCo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItem(int pSlot, ItemStack pStack) {
|
public void setItem(int pSlot, ItemStack pStack) {
|
||||||
ItemStack itemstack = this.items.get(pSlot);
|
|
||||||
boolean flag = !pStack.isEmpty() && ItemStack.isSameItemSameTags(itemstack, pStack);
|
|
||||||
this.items.set(pSlot, pStack);
|
this.items.set(pSlot, pStack);
|
||||||
if (pStack.getCount() > this.getMaxStackSize()) {
|
if (pStack.getCount() > this.getMaxStackSize()) {
|
||||||
pStack.setCount(this.getMaxStackSize());
|
pStack.setCount(this.getMaxStackSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSlot == 0 && !flag) {
|
|
||||||
this.setChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1427,8 +1427,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"origin": [20.24978, 2.55382, -62.10718],
|
"origin": [-20.24972, 2.55382, -62.10718],
|
||||||
"size": [-40.49955, 15.58061, 1.31153],
|
"size": [40.4995, 15.58061, 1.31153],
|
||||||
"pivot": [0, 2.80382, -58.99183],
|
"pivot": [0, 2.80382, -58.99183],
|
||||||
"rotation": [-30, 0, 0],
|
"rotation": [-30, 0, 0],
|
||||||
"uv": {
|
"uv": {
|
||||||
|
|
|
@ -1111,8 +1111,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"origin": [20.24978, 2.55382, -62.10718],
|
"origin": [-20.24972, 2.55382, -62.10718],
|
||||||
"size": [-40.49955, 15.58061, 1.31153],
|
"size": [40.4995, 15.58061, 0.31153],
|
||||||
"pivot": [0, 2.80382, -58.99183],
|
"pivot": [0, 2.80382, -58.99183],
|
||||||
"rotation": [-30, 0, 0],
|
"rotation": [-30, 0, 0],
|
||||||
"uv": {
|
"uv": {
|
||||||
|
|
Loading…
Add table
Reference in a new issue