mango deserves the death penalty istg
This commit is contained in:
@@ -28,10 +28,9 @@ public class CreateTFMG implements ModInitializer {
|
||||
public static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
static {
|
||||
REGISTRATE.setTooltipModifierFactory(item -> {
|
||||
return new ItemDescription.Modifier(item, TooltipHelper.Palette.STANDARD_CREATE)
|
||||
.andThen(TooltipModifier.mapNull(KineticStats.create(item)));
|
||||
});
|
||||
REGISTRATE.setTooltipModifierFactory(item ->
|
||||
new ItemDescription.Modifier(item, TooltipHelper.Palette.STANDARD_CREATE)
|
||||
.andThen(TooltipModifier.mapNull(KineticStats.create(item))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,8 +4,10 @@ import java.util.Collection;
|
||||
|
||||
import com.drmangotea.createindustry.CreateTFMG;
|
||||
import com.simibubi.create.compat.jei.CreateJEI;
|
||||
import com.simibubi.create.infrastructure.item.CreateCreativeModeTab;
|
||||
import com.tterrag.registrate.util.entry.RegistryEntry;
|
||||
|
||||
import io.github.fabricators_of_create.porting_lib.util.ItemGroupUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
@@ -18,7 +20,7 @@ import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public abstract class TFMGCreativeModeTab extends CreativeModeTab {
|
||||
public TFMGCreativeModeTab(String id) {
|
||||
super(CreateTFMG.MOD_ID + "." + id);
|
||||
super(ItemGroupUtil.expandArrayAndGetId(), CreateTFMG.MOD_ID + "." + id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.drmangotea.createindustry.base.util;
|
||||
|
||||
import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
|
||||
import com.simibubi.create.foundation.item.SmartInventory;
|
||||
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
|
||||
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
|
||||
import net.fabricmc.fabric.api.transfer.v1.storage.base.CombinedStorage;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class CombinedStorageWrapper extends CombinedStorage<ItemVariant, Storage<ItemVariant>> {
|
||||
|
||||
@SafeVarargs
|
||||
public CombinedStorageWrapper(Storage<ItemVariant>... parts) {
|
||||
super(Arrays.stream(parts).toList());
|
||||
}
|
||||
|
||||
// public CombinedStorageWrapper(SmartInventory... invs) {
|
||||
// super();
|
||||
// }
|
||||
}
|
||||
@@ -4,14 +4,20 @@ import com.drmangotea.createindustry.base.ElectricSparkParticle;
|
||||
import com.drmangotea.createindustry.base.util.spark.Spark;
|
||||
import com.drmangotea.createindustry.registry.TFMGEntityTypes;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
import io.github.fabricators_of_create.porting_lib.mixin.common.ProjectileUtilMixin;
|
||||
import io.github.fabricators_of_create.porting_lib.transfer.TransferUtil;
|
||||
import io.github.fabricators_of_create.porting_lib.transfer.fluid.FluidTank;
|
||||
import io.github.fabricators_of_create.porting_lib.util.FluidStack;
|
||||
import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityEvent;
|
||||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -70,4 +76,29 @@ public class TFMGUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void drain(FluidTank tank, long amount) {
|
||||
try (Transaction t = TransferUtil.getTransaction()) {
|
||||
tank.extract(tank.variant, amount, t);
|
||||
t.commit();
|
||||
}
|
||||
}
|
||||
|
||||
public static long fill(FluidTank tank, FluidStack fluid) {
|
||||
if (!tank.isEmpty() && tank.variant != fluid.getType())
|
||||
throw new RuntimeException("fluid variant being filled into tank isn't the same variant as the fluid in the tank");
|
||||
try (Transaction t = TransferUtil.getTransaction()) {
|
||||
tank.insert(fluid.getType(), fluid.getAmount(), t);
|
||||
t.commit();
|
||||
}
|
||||
return fluid.getAmount();
|
||||
}
|
||||
|
||||
// public static boolean mobGriefingEvent(Level level, Entity entity) {
|
||||
// EntityEvent event = ProjectileUtil.;
|
||||
// MinecraftForge.EVENT_BUS.post(event);
|
||||
// boolean result = event.getResult();
|
||||
// return result == Result.DEFAULT ? level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) : result == Result.ALLOW;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.world.entity.*;
|
||||
import net.minecraft.world.entity.projectile.ThrowableProjectile;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
@@ -78,7 +79,7 @@ public class BlueSpark extends ThrowableProjectile {
|
||||
super.onHitBlock(p_37384_);
|
||||
if (!this.level.isClientSide) {
|
||||
Entity entity = this.getOwner();
|
||||
if (!(entity instanceof Mob) || mobGriefingEvent(this.level, this)) {
|
||||
if (!(entity instanceof Mob) || level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
BlockPos blockpos = p_37384_.getBlockPos().relative(p_37384_.getDirection());
|
||||
if (this.level.isEmptyBlock(blockpos)) {
|
||||
this.level.setBlockAndUpdate(blockpos, BlueFireBlock.getState(this.level, blockpos));
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.drmangotea.createindustry.base.util.spark;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.items.weapons.explosives.pipe_bomb.PipeBomb;
|
||||
import com.drmangotea.createindustry.items.weapons.explosives.thermite_grenades.fire.GreenFireBlock;
|
||||
import com.drmangotea.createindustry.registry.TFMGEntityTypes;
|
||||
import com.drmangotea.createindustry.registry.TFMGItems;
|
||||
@@ -13,6 +12,7 @@ import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.world.entity.*;
|
||||
import net.minecraft.world.entity.projectile.ThrowableProjectile;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
@@ -78,7 +78,7 @@ public class GreenSpark extends ThrowableProjectile {
|
||||
super.onHitBlock(p_37384_);
|
||||
if (!this.level.isClientSide) {
|
||||
Entity entity = this.getOwner();
|
||||
if (!(entity instanceof Mob) || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level, this)) {
|
||||
if (!(entity instanceof Mob) || level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
BlockPos blockpos = p_37384_.getBlockPos().relative(p_37384_.getDirection());
|
||||
if (this.level.isEmptyBlock(blockpos)) {
|
||||
this.level.setBlockAndUpdate(blockpos, GreenFireBlock.getState(this.level, blockpos));
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.drmangotea.createindustry.base.util.spark;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.items.weapons.explosives.pipe_bomb.PipeBomb;
|
||||
import com.drmangotea.createindustry.registry.TFMGEntityTypes;
|
||||
import com.drmangotea.createindustry.registry.TFMGItems;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
|
||||
@@ -11,6 +10,7 @@ import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.world.entity.*;
|
||||
import net.minecraft.world.entity.projectile.ThrowableProjectile;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BaseFireBlock;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
@@ -74,7 +74,7 @@ public class Spark extends ThrowableProjectile {
|
||||
super.onHitBlock(p_37384_);
|
||||
if (!this.level.isClientSide) {
|
||||
Entity entity = this.getOwner();
|
||||
if (!(entity instanceof Mob) || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level, this)) {
|
||||
if (!(entity instanceof Mob) || level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
BlockPos blockpos = p_37384_.getBlockPos().relative(p_37384_.getDirection());
|
||||
if (this.level.isEmptyBlock(blockpos)) {
|
||||
this.level.setBlockAndUpdate(blockpos, BaseFireBlock.getState(this.level, blockpos));
|
||||
|
||||
@@ -1,33 +1,39 @@
|
||||
package com.drmangotea.createindustry.blocks.electricity.api;
|
||||
|
||||
import net.fabricmc.fabric.api.transfer.v1.storage.TransferVariant;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import com.drmangotea.createindustry.blocks.electricity.base.IElectricBlock;
|
||||
|
||||
public class Energy implements TransferVariant<Double> {
|
||||
@Override
|
||||
public boolean isBlank() {
|
||||
return false;
|
||||
import static org.apache.commons.lang3.ObjectUtils.min;
|
||||
|
||||
public class Energy {
|
||||
long voltage;
|
||||
long current;
|
||||
|
||||
public Energy(long voltage, long current) {
|
||||
this.current = current;
|
||||
this.voltage = current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getObject() {
|
||||
return null;
|
||||
public long getVoltage() {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable CompoundTag getNbt() {
|
||||
return null;
|
||||
public long getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toNbt() {
|
||||
return null;
|
||||
public long discharge(long amount, boolean simulate) {
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toPacket(FriendlyByteBuf buf) {
|
||||
public long charge(long amount, boolean simulate) {
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
public long transfer(IElectricBlock to, long amount, boolean simulate) {
|
||||
long discharge = discharge(amount, true);
|
||||
long charge = to.getStorage().charge(amount, true);
|
||||
return min(discharge, charge);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.drmangotea.createindustry.blocks.electricity.api;
|
||||
|
||||
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleVariantStorage;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public class EnergyStorage extends SingleVariantStorage<Energy> {
|
||||
|
||||
|
||||
public EnergyStorage(long i) {
|
||||
this.variant = new Energy();
|
||||
this.amount = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Energy getBlankVariant() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long getCapacity(Energy variant) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -28,11 +28,6 @@ public class ConverterBlockEntity extends ElectricBlockEntity {
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.drmangotea.createindustry.blocks.electricity.base;
|
||||
|
||||
import com.drmangotea.createindustry.CreateTFMG;
|
||||
import com.drmangotea.createindustry.blocks.electricity.capacitor.CapacitorBlockEntity;
|
||||
import com.drmangotea.createindustry.blocks.electricity.api.Energy;
|
||||
import com.drmangotea.createindustry.blocks.electricity.resistors.ResistorBlockEntity;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.simibubi.create.Create;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -13,24 +11,18 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
public interface IElectricBlock {
|
||||
|
||||
|
||||
|
||||
float internalResistance();
|
||||
|
||||
Energy getStorage();
|
||||
|
||||
int getVoltage();
|
||||
|
||||
boolean gotFElastTick(int value);
|
||||
|
||||
int getCurrent();
|
||||
|
||||
|
||||
int feGeneration();
|
||||
|
||||
int voltageGeneration();
|
||||
|
||||
int transferSpeed();
|
||||
|
||||
|
||||
void addVoltage(float amount);
|
||||
|
||||
default float getCharge(){
|
||||
@@ -41,22 +33,14 @@ public interface IElectricBlock {
|
||||
return false;
|
||||
}
|
||||
|
||||
TFMGForgeEnergyStorage getForgeEnergy();
|
||||
|
||||
boolean hasElectricitySlot(Direction direction);
|
||||
|
||||
|
||||
float maxVoltage();
|
||||
|
||||
void explode();
|
||||
|
||||
int FECapacity();
|
||||
|
||||
|
||||
int getDistanceFromSource();
|
||||
|
||||
|
||||
|
||||
void setDistanceFromSource(int value);
|
||||
|
||||
void sendStuff();
|
||||
@@ -75,8 +59,6 @@ public interface IElectricBlock {
|
||||
|
||||
boolean getsVoltageFromNonTFMGBlock = false;
|
||||
|
||||
|
||||
|
||||
if(canBeDisabled()){
|
||||
|
||||
|
||||
@@ -92,37 +74,29 @@ public interface IElectricBlock {
|
||||
|
||||
if(be1 instanceof IElectricBlock be2){
|
||||
|
||||
|
||||
|
||||
if(be2.hasElectricitySlot(direction.getOpposite())) {
|
||||
|
||||
|
||||
|
||||
int distance = be2.getDistanceFromSource();
|
||||
|
||||
|
||||
if(!isStorage()&&be2.isStorage()&&direction == Direction.UP)
|
||||
distance = Integer.MAX_VALUE;
|
||||
|
||||
|
||||
if(getVoltage()==0) {
|
||||
if(distance>getDistanceFromSource())
|
||||
be2.addVoltage(getVoltage());
|
||||
}
|
||||
|
||||
if(!(be2 instanceof ConverterBlockEntity))
|
||||
if(!(isStorage()&&direction == Direction.DOWN))
|
||||
if(!(!isStorage()&&be2.isStorage()&&direction == Direction.DOWN))
|
||||
if(getVoltage()!=0) {
|
||||
// if(Create.RANDOM.nextInt(3) ==1)
|
||||
transferCharge(be2);
|
||||
if(distance>getDistanceFromSource()){
|
||||
be2.addVoltage(getVoltage());
|
||||
}
|
||||
}
|
||||
|
||||
lowestDistance = Math.min(lowestDistance,distance);
|
||||
|
||||
if(!(isStorage()&&direction == Direction.DOWN))
|
||||
if(!(!isStorage()&&be2.isStorage()&&direction == Direction.DOWN))
|
||||
if(getVoltage()!=0) {
|
||||
// if(Create.RANDOM.nextInt(3) ==1)
|
||||
transferCharge(be2);
|
||||
if(distance>getDistanceFromSource())
|
||||
be2.addVoltage(getVoltage());
|
||||
}
|
||||
lowestDistance = Math.min(lowestDistance,distance);
|
||||
}
|
||||
if(direction.getAxis().isHorizontal()) {
|
||||
if (be2 instanceof ResistorBlockEntity resistorBE)
|
||||
@@ -133,11 +107,7 @@ public interface IElectricBlock {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}else
|
||||
|
||||
if(be1!=null) {
|
||||
} else if(be1!=null) {
|
||||
if (be1.getCapability(ForgeCapabilities.ENERGY, direction.getOpposite()).isPresent()) {
|
||||
|
||||
if (!(be1.getCapability(ForgeCapabilities.ENERGY, direction.getOpposite()).orElse(new EnergyStorage(0)) instanceof TFMGForgeEnergyStorage)) {
|
||||
@@ -216,114 +186,47 @@ public interface IElectricBlock {
|
||||
addVoltage(0);
|
||||
}
|
||||
|
||||
|
||||
//PLUH
|
||||
|
||||
default void transferCharge(IElectricBlock be) {
|
||||
|
||||
|
||||
|
||||
if(!isStorage()) {
|
||||
if (be.getDistanceFromSource() > getDistanceFromSource()||be.isStorage()) {
|
||||
|
||||
//int amount = getForgeEnergy().extractEnergy(transferSpeed(), true);
|
||||
//int amount2 = be.getForgeEnergy().receiveEnergy( transferSpeed(), true);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int amount = getForgeEnergy().extractEnergy(transferSpeed()*100, true);
|
||||
int amount2 = be.getForgeEnergy().receiveEnergy(transferSpeed()*100, true);
|
||||
|
||||
|
||||
getForgeEnergy().extractEnergy(Math.min(amount, amount2), false);
|
||||
be.getForgeEnergy().receiveEnergy(Math.min(amount, amount2), false);
|
||||
}
|
||||
if(be.getDistanceFromSource()==getDistanceFromSource()&&getForgeEnergy().getEnergyStored()>be.getForgeEnergy().getEnergyStored()){
|
||||
|
||||
int diff = Math.abs(getForgeEnergy().getEnergyStored()-be.getForgeEnergy().getEnergyStored());
|
||||
|
||||
int amount = getForgeEnergy().extractEnergy(diff / 2, true);
|
||||
int amount2 = be.getForgeEnergy().receiveEnergy( diff / 2, true);
|
||||
getForgeEnergy().extractEnergy( Math.min(amount,amount2), false);
|
||||
be.getForgeEnergy().receiveEnergy( Math.min(amount,amount2), false);
|
||||
boolean hasHigherVoltage = getStorage().getVoltage() > be.getStorage().getVoltage();
|
||||
if(isStorage()) {
|
||||
if(be.isStorage() && !hasHigherVoltage) {
|
||||
long amount = getStorage().transfer(be, transferSpeed() * 10, true);
|
||||
getStorage().transfer(be, amount, false);
|
||||
} else {
|
||||
long amount = be.getStorage().transfer(be, transferSpeed(), true);
|
||||
getStorage().transfer(be, amount, false);
|
||||
}
|
||||
} else {
|
||||
if (be.getDistanceFromSource() > getDistanceFromSource() || be.isStorage()) {
|
||||
long amount = getStorage().transfer(be, transferSpeed()*100, true);
|
||||
getStorage().transfer(be, amount, false);
|
||||
}
|
||||
if(be.getDistanceFromSource() == getDistanceFromSource() && hasHigherVoltage){
|
||||
|
||||
long diff = Math.abs(getStorage().getVoltage() - be.getStorage().getVoltage());
|
||||
|
||||
long amount = getStorage().transfer(be, diff / 2, true);
|
||||
getStorage().transfer(be, amount, false);
|
||||
}
|
||||
}
|
||||
|
||||
if(isStorage()){
|
||||
if(be.isStorage()){
|
||||
|
||||
if(!be.isStorage()||(be.isStorage()&&be.getForgeEnergy().getEnergyStored()<getForgeEnergy().getEnergyStored())) {
|
||||
// if(be.getDistanceFromSource()>=getDistanceFromSource()) {
|
||||
int amount = getForgeEnergy().extractEnergy(transferSpeed()*10, true);
|
||||
int amount2 = be.getForgeEnergy().receiveEnergy(transferSpeed()*10, true);
|
||||
|
||||
|
||||
getForgeEnergy().extractEnergy(Math.min(amount, amount2), false);
|
||||
be.getForgeEnergy().receiveEnergy(Math.min(amount, amount2), false);
|
||||
}
|
||||
|
||||
}else {
|
||||
int amount = getForgeEnergy().extractEnergy(transferSpeed(), true);
|
||||
int amount2 = be.getForgeEnergy().receiveEnergy(transferSpeed(), true);
|
||||
|
||||
|
||||
//if(be.getForgeEnergy().getEnergyStored()<be.getForgeEnergy().getMaxEnergyStored()/2) {
|
||||
getForgeEnergy().extractEnergy(Math.min(amount, amount2), false);
|
||||
be.getForgeEnergy().receiveEnergy(Math.min(amount, amount2), false);
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//PLUH
|
||||
|
||||
default void useEnergy(int baseValue){
|
||||
|
||||
getForgeEnergy().extractEnergy(baseValue/(voltageGeneration()+1),false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
default TFMGForgeEnergyStorage createEnergyStorage(){
|
||||
return new TFMGForgeEnergyStorage(FECapacity(), 99999) {
|
||||
@Override
|
||||
public void onEnergyChanged(int energyAmount,boolean setEnergy) {
|
||||
|
||||
if(setEnergy)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
gotFElastTick(1);
|
||||
|
||||
|
||||
sendStuff();
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
getStorage().discharge(baseValue/(voltageGeneration()+1),false);
|
||||
}
|
||||
|
||||
|
||||
default void writeElectrity(CompoundTag compound){
|
||||
|
||||
compound.putInt("Voltage",getVoltage());
|
||||
compound.putInt("Current",getCurrent());
|
||||
compound.putDouble("Voltage",getVoltage());
|
||||
compound.putDouble("Current",getCurrent());
|
||||
|
||||
compound.putInt("DistanceFromSource",getDistanceFromSource());
|
||||
|
||||
compound.putInt("ForgeEnergy", getForgeEnergy().getEnergyStored());
|
||||
//compound.putInt("ForgeEnergy", getForgeEnergy().getEnergyStored());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.drmangotea.createindustry.blocks.electricity.base;
|
||||
|
||||
public abstract class TFMGForgeEnergyStorage extends EnergyStorage {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public TFMGForgeEnergyStorage(int capacity, int maxTransfer) {
|
||||
super(capacity, maxTransfer);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate) {
|
||||
int extractedEnergy = super.extractEnergy(maxExtract, simulate);
|
||||
if(extractedEnergy != 0) {
|
||||
onEnergyChanged(maxExtract*-1,false);
|
||||
}
|
||||
|
||||
return extractedEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(int maxReceive, boolean simulate) {
|
||||
int receiveEnergy = super.receiveEnergy(maxReceive, simulate);
|
||||
if(receiveEnergy != 0) {
|
||||
onEnergyChanged(receiveEnergy,false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return receiveEnergy;
|
||||
}
|
||||
|
||||
public int setEnergy(int energy) {
|
||||
this.energy = energy;
|
||||
|
||||
if(energy>0)
|
||||
onEnergyChanged(energy,true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public abstract void onEnergyChanged(int amount, boolean setEnergy);
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.drmangotea.createindustry.blocks.electricity.base.cables;
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGTools;
|
||||
import com.drmangotea.createindustry.blocks.electricity.api.EnergyStorage;
|
||||
import com.drmangotea.createindustry.blocks.electricity.base.*;
|
||||
import com.drmangotea.createindustry.blocks.electricity.resistors.ResistorBlockEntity;
|
||||
import com.drmangotea.createindustry.registry.TFMGItems;
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package com.drmangotea.createindustry.blocks.electricity.base.cables.test;
|
||||
|
||||
import com.drmangotea.createindustry.blocks.electricity.base.TFMGForgeEnergyStorage;
|
||||
|
||||
public class ElectricalNetworkMember {
|
||||
|
||||
public int voltage;
|
||||
|
||||
public TFMGForgeEnergyStorage energy;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.simibubi.create.AllTags;
|
||||
import com.simibubi.create.content.decoration.copycat.CopycatModel;
|
||||
import com.simibubi.create.content.equipment.wrench.IWrenchable;
|
||||
import com.simibubi.create.foundation.block.IBE;
|
||||
import io.github.fabricators_of_create.porting_lib.block.CustomSoundTypeBlock;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -38,7 +39,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CopycatCableBlock extends Block implements IBE<CopycatCableBlockEntity>, IWrenchable {
|
||||
public class CopycatCableBlock extends Block implements IBE<CopycatCableBlockEntity>, IWrenchable, CustomSoundTypeBlock {
|
||||
|
||||
public CopycatCableBlock(Properties pProperties) {
|
||||
super(pProperties);
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.drmangotea.createindustry.blocks.electricity.cable_blocks.copycat_ca
|
||||
|
||||
import com.drmangotea.createindustry.base.util.TFMGUtils;
|
||||
import com.drmangotea.createindustry.blocks.electricity.base.IElectricBlock;
|
||||
import com.drmangotea.createindustry.blocks.electricity.base.TFMGForgeEnergyStorage;
|
||||
import com.simibubi.create.content.decoration.copycat.CopycatBlockEntity;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.drmangotea.createindustry.blocks.electricity.electric_motor;
|
||||
|
||||
import com.drmangotea.createindustry.base.util.TFMGUtils;
|
||||
import com.drmangotea.createindustry.blocks.electricity.base.IElectricBlock;
|
||||
import com.drmangotea.createindustry.blocks.electricity.base.TFMGForgeEnergyStorage;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.github.fabricators_of_create.porting_lib.util.LazyOptional;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
||||
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -43,7 +44,9 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.drmangotea.createindustry.base.util.TFMGUtils.fill;
|
||||
import static com.drmangotea.createindustry.blocks.engines.diesel.DieselEngineBlock.FACE;
|
||||
import static net.minecraft.world.level.block.HorizontalDirectionalBlock.FACING;
|
||||
|
||||
@@ -340,8 +343,8 @@ public class DieselEngineBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
//airTank.drain(1, IFluidHandler.FluidAction.EXECUTE);
|
||||
if(!airTank.isEmpty()) {
|
||||
airTank.setFluid(new FluidStack(FluidVariant.of(TFMGFluids.AIR.getSource()), airTank.getFluidAmount() - 5));
|
||||
}else expansionBE.airTank.setFluid(new FluidStack(TFMGFluids.AIR.getSource(), expansionBE.airTank.getFluidAmount() - 5));
|
||||
exhaustTank.fill(new FluidStack(FluidVariant.of(TFMGFluids.CARBON_DIOXIDE.getSource()),3), IFluidHandler.FluidAction.EXECUTE);
|
||||
}else expansionBE.airTank.setFluid(new FluidStack(FluidVariant.of(TFMGFluids.AIR.getSource()), expansionBE.airTank.getFluidAmount() - 5));
|
||||
fill(exhaustTank, new FluidStack(FluidVariant.of(TFMGFluids.CARBON_DIOXIDE.getSource()),3));
|
||||
//tanks.get(false).setFluid(new FluidStack(TFMGFluids.CARBON_DIOXIDE.getSource(), tanks.get(false).getFluidAmount()+1));
|
||||
|
||||
|
||||
@@ -517,13 +520,13 @@ public class DieselEngineBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
|
||||
|
||||
//--Fluid Info--//
|
||||
LazyOptional<IFluidHandler> handler = this.getCapability(ForgeCapabilities.FLUID_HANDLER);
|
||||
Optional<IFluidHandler> resolve = handler.resolve();
|
||||
LazyOptional<CombinedTankWrapper> handler = fluidCapability;
|
||||
Optional<CombinedTankWrapper> resolve = handler.resolve();
|
||||
if (!resolve.isPresent())
|
||||
return false;
|
||||
|
||||
IFluidHandler tank = resolve.get();
|
||||
if (tank.getTanks() == 0)
|
||||
CombinedTankWrapper tanks = resolve.get();
|
||||
if (tanks.parts.isEmpty())
|
||||
return false;
|
||||
|
||||
LangBuilder mb = Lang.translate("generic.unit.millibuckets");
|
||||
@@ -532,8 +535,9 @@ public class DieselEngineBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
.forGoggles(tooltip);
|
||||
|
||||
boolean isEmpty = true;
|
||||
for (int i = 0; i < tank.getTanks(); i++) {
|
||||
FluidStack fluidStack = tank.getFluidInTank(i);
|
||||
for (int i = 0; i < tanks.parts.size(); i++) {
|
||||
Storage<FluidVariant> tank = tanks.parts.get(i);
|
||||
FluidStack fluidStack = tank.iterator();
|
||||
if (fluidStack.isEmpty())
|
||||
continue;
|
||||
|
||||
@@ -546,7 +550,7 @@ public class DieselEngineBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
.add(mb)
|
||||
.style(ChatFormatting.DARK_GREEN))
|
||||
.text(ChatFormatting.GRAY, " / ")
|
||||
.add(Lang.number(tank.getTankCapacity(i))
|
||||
.add(Lang.number(tanks.getTankCapacity(i))
|
||||
.add(mb)
|
||||
.style(ChatFormatting.DARK_GRAY))
|
||||
.forGoggles(tooltip, 1);
|
||||
@@ -554,7 +558,7 @@ public class DieselEngineBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
isEmpty = false;
|
||||
}
|
||||
|
||||
if (tank.getTanks() > 1) {
|
||||
if (tanks.getTanks() > 1) {
|
||||
if (isEmpty)
|
||||
tooltip.remove(tooltip.size() - 1);
|
||||
return true;
|
||||
@@ -564,7 +568,7 @@ public class DieselEngineBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
return true;
|
||||
|
||||
Lang.translate("gui.goggles.fluid_container.capacity")
|
||||
.add(Lang.number(tank.getTankCapacity(0))
|
||||
.add(Lang.number(tanks.getTankCapacity(0))
|
||||
.add(mb)
|
||||
.style(ChatFormatting.DARK_GREEN))
|
||||
.style(ChatFormatting.DARK_GRAY)
|
||||
|
||||
@@ -13,7 +13,6 @@ import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ import com.simibubi.create.foundation.utility.LangBuilder;
|
||||
import io.github.fabricators_of_create.porting_lib.transfer.fluid.FluidTank;
|
||||
import io.github.fabricators_of_create.porting_lib.util.FluidStack;
|
||||
import io.github.fabricators_of_create.porting_lib.util.LazyOptional;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
||||
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -31,7 +33,7 @@ public class TFMGMachineBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
|
||||
private boolean contentsChanged;
|
||||
|
||||
protected LazyOptional<FluidTank> fluidCapability;
|
||||
protected LazyOptional<CombinedTankWrapper> fluidCapability;
|
||||
|
||||
public TFMGMachineBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
@@ -68,9 +70,9 @@ public class TFMGMachineBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
behaviours.add(tank2);
|
||||
|
||||
fluidCapability = LazyOptional.of(() -> {
|
||||
LazyOptional<? extends FluidTank> inputCap = tank1.getCapability();
|
||||
LazyOptional<? extends FluidTank> outputCap = tank2.getCapability();
|
||||
return new CombinedTankWrapper(outputCap.orElse(null), inputCap.orElse(null));
|
||||
Storage<FluidVariant> inputCap = tank1.getCapability();
|
||||
Storage<FluidVariant> outputCap = tank2.getCapability();
|
||||
return new CombinedTankWrapper(outputCap, inputCap);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.metal_processing.blast_furnace;
|
||||
|
||||
import com.drmangotea.createindustry.base.util.CombinedStorageWrapper;
|
||||
import com.drmangotea.createindustry.blocks.machines.TFMGMachineBlockEntity;
|
||||
import com.drmangotea.createindustry.recipes.industrial_blasting.IndustrialBlastingRecipe;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
@@ -7,19 +8,25 @@ import com.drmangotea.createindustry.registry.TFMGItems;
|
||||
import com.drmangotea.createindustry.registry.TFMGRecipeTypes;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.content.logistics.depot.DepotBlockEntity;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
import com.simibubi.create.foundation.item.ItemHelper;
|
||||
import com.simibubi.create.foundation.item.SmartInventory;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
|
||||
import io.github.fabricators_of_create.porting_lib.transfer.item.ItemStackHandler;
|
||||
import io.github.fabricators_of_create.porting_lib.transfer.item.RecipeWrapper;
|
||||
import io.github.fabricators_of_create.porting_lib.util.LazyOptional;
|
||||
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
|
||||
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
|
||||
import net.fabricmc.fabric.api.transfer.v1.storage.base.CombinedStorage;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
@@ -27,6 +34,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -58,14 +66,12 @@ public class BlastFurnaceOutputBlockEntity extends TFMGMachineBlockEntity implem
|
||||
public LerpedFloat coalCokeHeight = LerpedFloat.linear();
|
||||
|
||||
//item storage
|
||||
public LazyOptional<IItemHandlerModifiable> itemCapability;
|
||||
public LazyOptional<CombinedStorageWrapper> itemCapability;
|
||||
|
||||
public SmartInventory inputInventory;
|
||||
|
||||
public SmartInventory fuelInventory;
|
||||
|
||||
int debug = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -79,7 +85,7 @@ public class BlastFurnaceOutputBlockEntity extends TFMGMachineBlockEntity implem
|
||||
fuelInventory = new SmartInventory(1, this).forbidInsertion().forbidExtraction()
|
||||
.withMaxStackSize(64);
|
||||
|
||||
itemCapability = LazyOptional.of(() -> new Combined(inputInventory,fuelInventory));
|
||||
itemCapability = LazyOptional.of(() -> new CombinedStorageWrapper(inputInventory, fuelInventory));
|
||||
|
||||
|
||||
tank1.getPrimaryHandler().setCapacity(8000);
|
||||
|
||||
@@ -5,14 +5,18 @@ import com.drmangotea.createindustry.blocks.tanks.SteelTankBlockEntity;
|
||||
import com.drmangotea.createindustry.recipes.distillation.DistillationRecipe;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.content.fluids.pipes.FluidPipeBlock;
|
||||
import com.simibubi.create.content.fluids.pump.PumpBlock;
|
||||
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
import com.simibubi.create.foundation.fluid.SmartFluidTank;
|
||||
import com.simibubi.create.foundation.recipe.RecipeFinder;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import io.github.fabricators_of_create.porting_lib.transfer.TransferUtil;
|
||||
import io.github.fabricators_of_create.porting_lib.transfer.fluid.FluidTank;
|
||||
import io.github.fabricators_of_create.porting_lib.util.FluidStack;
|
||||
import io.github.fabricators_of_create.porting_lib.util.LazyOptional;
|
||||
import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -29,6 +33,8 @@ import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.drmangotea.createindustry.base.util.TFMGUtils.fill;
|
||||
|
||||
public class DistillationControllerBlockEntity extends SmartBlockEntity implements IHaveGoggleInformation {
|
||||
|
||||
private static final Object DistillationRecipesKey = new Object();
|
||||
@@ -99,7 +105,7 @@ public class DistillationControllerBlockEntity extends SmartBlockEntity implemen
|
||||
|
||||
|
||||
for(DistillationOutputBlockEntity be1 : outputs){
|
||||
if(be1.tank==0)
|
||||
if(be1.tank.isEmpty())
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -114,15 +120,17 @@ public class DistillationControllerBlockEntity extends SmartBlockEntity implemen
|
||||
if(fluidStack.isEmpty())
|
||||
break;
|
||||
|
||||
if(output.tank.fill(new FluidStack(fluidStack, (int) (fluidStack.getAmount()*speedModifier)), IFluidHandler.FluidAction.SIMULATE)>output.tank.getCapacity())
|
||||
if(fill(output.tank, new FluidStack(fluidStack, (int) (fluidStack.getAmount()*speedModifier)))>output.tank.getCapacity())
|
||||
break;
|
||||
|
||||
|
||||
output.tank.fill(new FluidStack(fluidStack, (int) (fluidStack.getAmount()*speedModifier)), IFluidHandler.FluidAction.EXECUTE);
|
||||
fill(output.tank, new FluidStack(fluidStack, (int) (fluidStack.getAmount()*speedModifier)));
|
||||
int consumption = (recipe.getInputFluid().getRequiredAmount()/6);
|
||||
|
||||
|
||||
tank.drain((int) (consumption*speedModifier), IFluidHandler.FluidAction.EXECUTE);
|
||||
try (Transaction t = TransferUtil.getTransaction()) {
|
||||
tank.extract(tank.variant, (long) (consumption*speedModifier), t);
|
||||
t.commit();
|
||||
}
|
||||
|
||||
numero++;
|
||||
|
||||
|
||||
@@ -4,9 +4,13 @@ import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
import com.simibubi.create.foundation.fluid.SmartFluidTank;
|
||||
import io.github.fabricators_of_create.porting_lib.transfer.TransferUtil;
|
||||
import io.github.fabricators_of_create.porting_lib.transfer.fluid.FluidTank;
|
||||
import io.github.fabricators_of_create.porting_lib.util.FluidStack;
|
||||
import io.github.fabricators_of_create.porting_lib.util.LazyOptional;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
||||
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
|
||||
import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -20,12 +24,12 @@ import java.util.List;
|
||||
public class DistillationOutputBlockEntity extends SmartBlockEntity implements IHaveGoggleInformation {
|
||||
|
||||
|
||||
protected LazyOptional<FluidTank> fluidCapability;
|
||||
protected Storage<FluidVariant> fluidCapability;
|
||||
|
||||
public final FluidTank tank = new SmartFluidTank(8000,this::onFluidStackChanged);
|
||||
public DistillationOutputBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
fluidCapability = LazyOptional.of(()->tank);
|
||||
fluidCapability = tank.getSlot(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,8 +70,6 @@ public class DistillationOutputBlockEntity extends SmartBlockEntity implements I
|
||||
|
||||
|
||||
return containedFluidTooltip(tooltip, isPlayerSneaking,
|
||||
getCapability(ForgeCapabilities.FLUID_HANDLER));
|
||||
|
||||
|
||||
fluidCapability);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,12 @@ import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour
|
||||
import com.simibubi.create.foundation.fluid.SmartFluidTank;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.LangBuilder;
|
||||
import io.github.fabricators_of_create.porting_lib.transfer.TransferUtil;
|
||||
import io.github.fabricators_of_create.porting_lib.transfer.fluid.FluidTank;
|
||||
import io.github.fabricators_of_create.porting_lib.util.FluidStack;
|
||||
import io.github.fabricators_of_create.porting_lib.util.LazyOptional;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
||||
import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -183,52 +185,36 @@ public class PumpjackBaseBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
}
|
||||
|
||||
//--Fluid Info--//
|
||||
LazyOptional<FluidTank> handler = this.getCapability(ForgeCapabilities.FLUID_HANDLER);
|
||||
LazyOptional<FluidTank> handler = fluidCapability;
|
||||
Optional<FluidTank> resolve = handler.resolve();
|
||||
if (!resolve.isPresent())
|
||||
return false;
|
||||
|
||||
FluidTank tank = resolve.get();
|
||||
if (tank.getTanks() == 0)
|
||||
return false;
|
||||
|
||||
FluidStack fluidStack = tank.getFluid();
|
||||
|
||||
Lang.fluidName(fluidStack)
|
||||
.style(ChatFormatting.GRAY)
|
||||
.forGoggles(tooltip, 1);
|
||||
|
||||
Lang.builder()
|
||||
.add(Lang.number(fluidStack.getAmount())
|
||||
.add(mb)
|
||||
.style(ChatFormatting.DARK_GREEN))
|
||||
.text(ChatFormatting.GRAY, " / ")
|
||||
.add(Lang.number(tank.getCapacity())
|
||||
.add(mb)
|
||||
.style(ChatFormatting.DARK_GRAY))
|
||||
.forGoggles(tooltip, 1);
|
||||
|
||||
boolean isEmpty = true;
|
||||
for (int i = 0; i < tank.getTanks(); i++) {
|
||||
FluidStack fluidStack = tank.getFluidInTank(i);
|
||||
if (fluidStack.isEmpty())
|
||||
continue;
|
||||
|
||||
Lang.fluidName(fluidStack)
|
||||
.style(ChatFormatting.GRAY)
|
||||
.forGoggles(tooltip, 1);
|
||||
|
||||
Lang.builder()
|
||||
.add(Lang.number(fluidStack.getAmount())
|
||||
.add(mb)
|
||||
.style(ChatFormatting.DARK_GREEN))
|
||||
.text(ChatFormatting.GRAY, " / ")
|
||||
.add(Lang.number(tank.getTankCapacity(i))
|
||||
.add(mb)
|
||||
.style(ChatFormatting.DARK_GRAY))
|
||||
.forGoggles(tooltip, 1);
|
||||
|
||||
isEmpty = false;
|
||||
}
|
||||
|
||||
if (tank.getTanks() > 1) {
|
||||
if (isEmpty)
|
||||
tooltip.remove(tooltip.size() - 1);
|
||||
return true;
|
||||
}
|
||||
boolean isEmpty = tank.isEmpty();
|
||||
|
||||
if (!isEmpty)
|
||||
return true;
|
||||
|
||||
Lang.translate("gui.goggles.fluid_container.capacity")
|
||||
.add(Lang.number(tank.getTankCapacity(0))
|
||||
.add(Lang.number(tank.getCapacity())
|
||||
.add(mb)
|
||||
.style(ChatFormatting.DARK_GREEN))
|
||||
.style(ChatFormatting.DARK_GRAY)
|
||||
|
||||
@@ -88,7 +88,7 @@ public class WeldingBehaviour extends BeltProcessingBehaviour {
|
||||
super.write(compound, clientPacket);
|
||||
|
||||
if (clientPacket) {
|
||||
compound.put("ParticleItems", NBTHelper.writeCompoundList(particleItems, ItemStack::serializeNBT));
|
||||
compound.put("ParticleItems", NBTHelper.writeCompoundList(particleItems, ItemStack::getTag));
|
||||
particleItems.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,14 @@ package com.drmangotea.createindustry.blocks.tanks;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGSpriteShifts;
|
||||
import com.simibubi.create.AllSpriteShifts;
|
||||
import com.simibubi.create.api.connectivity.ConnectivityHandler;
|
||||
import com.simibubi.create.content.fluids.tank.FluidTankCTBehaviour;
|
||||
import com.simibubi.create.content.fluids.tank.FluidTankModel;
|
||||
import com.simibubi.create.foundation.block.connected.CTModel;
|
||||
import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import io.github.fabricators_of_create.porting_lib.model.data.ModelData;
|
||||
import io.github.fabricators_of_create.porting_lib.model.data.ModelProperty;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -18,52 +17,40 @@ import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class SteelFluidTankModel extends CTModel {
|
||||
|
||||
protected static final ModelProperty<CullData> CULL_PROPERTY = new ModelProperty<>();
|
||||
|
||||
public static SteelFluidTankModel standard(BakedModel originalModel) {
|
||||
return new SteelFluidTankModel(originalModel, TFMGSpriteShifts.STEEL_FLUID_TANK, TFMGSpriteShifts.STEEL_FLUID_TANK_TOP,
|
||||
TFMGSpriteShifts.STEEL_FLUID_TANK_INNER);
|
||||
}
|
||||
|
||||
|
||||
private SteelFluidTankModel(BakedModel originalModel, CTSpriteShiftEntry side, CTSpriteShiftEntry top,
|
||||
CTSpriteShiftEntry inner) {
|
||||
super(originalModel, new FluidTankCTBehaviour(side, top, inner));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ModelData.Builder gatherModelData(ModelData.Builder builder, BlockAndTintGetter world, BlockPos pos, BlockState state,
|
||||
ModelData blockEntityData) {
|
||||
super.gatherModelData(builder, world, pos, state, blockEntityData);
|
||||
CullData cullData = new CullData();
|
||||
public void emitBlockQuads(BlockAndTintGetter blockView, BlockState state, BlockPos pos, Supplier<RandomSource> randomSupplier, RenderContext context) {
|
||||
SteelFluidTankModel.CullData cullData = new SteelFluidTankModel.CullData();
|
||||
for (Direction d : Iterate.horizontalDirections)
|
||||
cullData.setCulled(d, ConnectivityHandler.isConnected(world, pos, pos.relative(d)));
|
||||
return builder.with(CULL_PROPERTY, cullData);
|
||||
cullData.setCulled(d, ConnectivityHandler.isConnected(blockView, pos, pos.relative(d)));
|
||||
|
||||
context.pushTransform(quad -> {
|
||||
Direction cullFace = quad.cullFace();
|
||||
if (cullFace != null && cullData.isCulled(cullFace)) {
|
||||
return false;
|
||||
}
|
||||
quad.cullFace(null);
|
||||
return true;
|
||||
});
|
||||
super.emitBlockQuads(blockView, state, pos, randomSupplier, context);
|
||||
context.popTransform();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(BlockState state, Direction side, RandomSource rand, ModelData extraData, RenderType renderType) {
|
||||
if (side != null)
|
||||
return Collections.emptyList();
|
||||
|
||||
List<BakedQuad> quads = new ArrayList<>();
|
||||
for (Direction d : Iterate.directions) {
|
||||
if (extraData.has(CULL_PROPERTY) && extraData.get(CULL_PROPERTY)
|
||||
.isCulled(d))
|
||||
continue;
|
||||
quads.addAll(super.getQuads(state, d, rand, extraData, renderType));
|
||||
}
|
||||
quads.addAll(super.getQuads(state, null, rand, extraData, renderType));
|
||||
return quads;
|
||||
}
|
||||
private class CullData {
|
||||
private static class CullData {
|
||||
boolean[] culledFaces;
|
||||
|
||||
public CullData() {
|
||||
@@ -87,3 +74,4 @@ public class SteelFluidTankModel extends CTModel {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.AllPartialModels;
|
||||
import com.simibubi.create.content.fluids.tank.FluidTankBlockEntity;
|
||||
import com.simibubi.create.content.fluids.tank.FluidTankRenderer;
|
||||
import com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.fluid.FluidRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
@@ -13,6 +15,7 @@ import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
|
||||
import io.github.fabricators_of_create.porting_lib.transfer.fluid.FluidTank;
|
||||
import io.github.fabricators_of_create.porting_lib.util.FluidStack;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariantAttributes;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
@@ -25,40 +28,40 @@ public class SteelFluidTankRenderer extends SafeBlockEntityRenderer<SteelTankBlo
|
||||
public SteelFluidTankRenderer(BlockEntityRendererProvider.Context context) {}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(SteelTankBlockEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(SteelTankBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
if (!te.isController())
|
||||
if (!be.isController())
|
||||
return;
|
||||
if (!te.window) {
|
||||
if (te.isDistillationTower)
|
||||
renderAsDistillationTower(te, partialTicks, ms, buffer, light, overlay);
|
||||
if (!be.window) {
|
||||
if (be.isDistillationTower)
|
||||
renderAsDistillationTower(be, partialTicks, ms, buffer, light, overlay);
|
||||
return;
|
||||
}
|
||||
|
||||
LerpedFloat fluidLevel = te.getFluidLevel();
|
||||
LerpedFloat fluidLevel = be.getFluidLevel();
|
||||
if (fluidLevel == null)
|
||||
return;
|
||||
|
||||
float capHeight = 1 / 4f;
|
||||
float tankHullWidth = 1 / 16f + 1 / 128f;
|
||||
float minPuddleHeight = 1 / 16f;
|
||||
float totalHeight = te.height - 2 * capHeight - minPuddleHeight;
|
||||
float totalHeight = be.height - 2 * capHeight - minPuddleHeight;
|
||||
|
||||
float level = fluidLevel.getValue(partialTicks);
|
||||
if (level < 1 / (512f * totalHeight))
|
||||
return;
|
||||
float clampedLevel = Mth.clamp(level * totalHeight, 0, totalHeight);
|
||||
|
||||
FluidTank tank = te.tankInventory;
|
||||
FluidTank tank = be.tankInventory;
|
||||
FluidStack fluidStack = tank.getFluid();
|
||||
|
||||
if (fluidStack.isEmpty())
|
||||
return;
|
||||
|
||||
boolean top = fluidStack.getType().getFluid().defaultFluidState().is;
|
||||
boolean top = FluidVariantAttributes.isLighterThanAir(fluidStack.getType());
|
||||
|
||||
float xMin = tankHullWidth;
|
||||
float xMax = xMin + te.width - 2 * tankHullWidth;
|
||||
float xMax = xMin + be.width - 2 * tankHullWidth;
|
||||
float yMin = totalHeight + capHeight + minPuddleHeight - clampedLevel;
|
||||
float yMax = yMin + clampedLevel;
|
||||
|
||||
@@ -68,7 +71,7 @@ public class SteelFluidTankRenderer extends SafeBlockEntityRenderer<SteelTankBlo
|
||||
}
|
||||
|
||||
float zMin = tankHullWidth;
|
||||
float zMax = zMin + te.width - 2 * tankHullWidth;
|
||||
float zMax = zMin + be.width - 2 * tankHullWidth;
|
||||
|
||||
ms.pushPose();
|
||||
ms.translate(0, clampedLevel - totalHeight, 0);
|
||||
@@ -76,13 +79,13 @@ public class SteelFluidTankRenderer extends SafeBlockEntityRenderer<SteelTankBlo
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
protected void renderAsDistillationTower(SteelTankBlockEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
BlockState blockState = te.getBlockState();
|
||||
protected void renderAsDistillationTower(SteelTankBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
BlockState blockState = be.getBlockState();
|
||||
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
|
||||
ms.pushPose();
|
||||
TransformStack msr = TransformStack.cast(ms);
|
||||
msr.translate(te.width / 2f, 0.5, te.width / 2f);
|
||||
msr.translate(be.width / 2f, 0.5, be.width / 2f);
|
||||
|
||||
float dialPivot = 5.75f / 16;
|
||||
|
||||
@@ -92,15 +95,15 @@ public class SteelFluidTankRenderer extends SafeBlockEntityRenderer<SteelTankBlo
|
||||
CachedBufferer.partial(TFMGPartialModels.TOWER_GAUGE, blockState)
|
||||
.rotateY(d.toYRot())
|
||||
.unCentre()
|
||||
.translate(te.width / 2f - 6 / 16f, 0, 0)
|
||||
.translate(be.width / 2f - 6 / 16f, 0, 0)
|
||||
.light(light)
|
||||
.renderInto(ms, vb);
|
||||
CachedBufferer.partial(AllPartialModels.BOILER_GAUGE_DIAL, blockState)
|
||||
.rotateY(d.toYRot())
|
||||
.unCentre()
|
||||
.translate(te.width / 2f - 6 / 16f, 0, 0)
|
||||
.translate(be.width / 2f - 6 / 16f, 0, 0)
|
||||
.translate(0, dialPivot, dialPivot)
|
||||
.rotateX(-te.visualGaugeRotation.getValue(partialTicks))
|
||||
.rotateX(-be.visualGaugeRotation.getValue(partialTicks))
|
||||
.translate(0, -dialPivot, -dialPivot)
|
||||
.light(light)
|
||||
.renderInto(ms, vb);
|
||||
@@ -111,8 +114,7 @@ public class SteelFluidTankRenderer extends SafeBlockEntityRenderer<SteelTankBlo
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderOffScreen(SteelTankBlockEntity te) {
|
||||
return te.isController();
|
||||
public boolean shouldRenderOffScreen(SteelTankBlockEntity be) {
|
||||
return be.isController();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,25 +4,34 @@ package com.drmangotea.createindustry.blocks.tanks;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.simibubi.create.api.connectivity.ConnectivityHandler;
|
||||
import com.simibubi.create.content.equipment.wrench.IWrenchable;
|
||||
import com.simibubi.create.content.fluids.tank.FluidTankBlockEntity;
|
||||
import com.simibubi.create.content.fluids.tank.FluidTankItem;
|
||||
import com.simibubi.create.content.fluids.transfer.GenericItemEmptying;
|
||||
import com.simibubi.create.content.fluids.transfer.GenericItemFilling;
|
||||
import com.simibubi.create.foundation.advancement.AdvancementBehaviour;
|
||||
import com.simibubi.create.foundation.block.IBE;
|
||||
import com.simibubi.create.foundation.blockEntity.ComparatorUtil;
|
||||
import com.simibubi.create.foundation.fluid.FluidHelper;
|
||||
import com.simibubi.create.foundation.fluid.FluidHelper.FluidExchange;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import io.github.fabricators_of_create.porting_lib.block.CustomSoundTypeBlock;
|
||||
import io.github.fabricators_of_create.porting_lib.transfer.TransferUtil;
|
||||
import io.github.fabricators_of_create.porting_lib.util.FluidStack;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariantAttributes;
|
||||
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.particles.BlockParticleOption;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.StringRepresentable;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
@@ -40,6 +49,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
@@ -47,33 +57,40 @@ import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class SteelTankBlock extends Block implements IWrenchable, IBE<SteelTankBlockEntity> {
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public static final BooleanProperty TOP = BooleanProperty.create("top");
|
||||
public static final BooleanProperty BOTTOM = BooleanProperty.create("bottom");
|
||||
public static final EnumProperty<Shape> SHAPE = EnumProperty.create("shape", Shape.class);
|
||||
import static com.simibubi.create.content.fluids.tank.FluidTankBlock.SILENCED_METAL;
|
||||
|
||||
private boolean creative;
|
||||
public class SteelTankBlock extends Block implements IWrenchable, IBE<SteelTankBlockEntity>, CustomSoundTypeBlock {
|
||||
|
||||
public static SteelTankBlock regular(Properties p_i48440_1_) {
|
||||
return new SteelTankBlock(p_i48440_1_, false);
|
||||
public static final BooleanProperty TOP = BooleanProperty.create("top");
|
||||
public static final BooleanProperty BOTTOM = BooleanProperty.create("bottom");
|
||||
public static final EnumProperty<Shape> SHAPE = EnumProperty.create("shape", Shape.class);
|
||||
public static final IntegerProperty LIGHT_LEVEL = IntegerProperty.create("light_level", 0, 15);
|
||||
|
||||
public static SteelTankBlock regular(Properties p_i48440_1_) {
|
||||
return new SteelTankBlock(p_i48440_1_);
|
||||
}
|
||||
|
||||
public static SteelTankBlock creative(Properties p_i48440_1_) {
|
||||
return new SteelTankBlock(p_i48440_1_, true);
|
||||
}
|
||||
@Override
|
||||
public void setPlacedBy(Level pLevel, BlockPos pPos, BlockState pState, LivingEntity pPlacer, ItemStack pStack) {
|
||||
super.setPlacedBy(pLevel, pPos, pState, pPlacer, pStack);
|
||||
AdvancementBehaviour.setPlacedBy(pLevel, pPos, pPlacer);
|
||||
}
|
||||
|
||||
protected SteelTankBlock(Properties p_i48440_1_) {
|
||||
super(setLightFunction(p_i48440_1_));
|
||||
registerDefaultState(defaultBlockState().setValue(TOP, true)
|
||||
.setValue(BOTTOM, true)
|
||||
.setValue(SHAPE, Shape.WINDOW)
|
||||
.setValue(LIGHT_LEVEL, 0));
|
||||
}
|
||||
|
||||
private static Properties setLightFunction(Properties properties) {
|
||||
return properties.lightLevel(state -> state.getValue(LIGHT_LEVEL));
|
||||
}
|
||||
|
||||
protected SteelTankBlock(Properties p_i48440_1_, boolean creative) {
|
||||
super(p_i48440_1_);
|
||||
this.creative = creative;
|
||||
registerDefaultState(defaultBlockState().setValue(TOP, true)
|
||||
.setValue(BOTTOM, true)
|
||||
.setValue(SHAPE, Shape.WINDOW));
|
||||
}
|
||||
|
||||
public static boolean isTank(BlockState state) {
|
||||
public static boolean isTank(BlockState state) {
|
||||
return state.getBlock() instanceof SteelTankBlock;
|
||||
}
|
||||
|
||||
@@ -83,7 +100,10 @@ public class SteelTankBlock extends Block implements IWrenchable, IBE<SteelTankB
|
||||
return;
|
||||
if (moved)
|
||||
return;
|
||||
withBlockEntityDo(world, pos, SteelTankBlockEntity::updateConnectivity);
|
||||
Consumer<SteelTankBlockEntity> consumer = FluidTankItem.IS_PLACING_NBT
|
||||
? SteelTankBlockEntity::queueConnectivityUpdate
|
||||
: SteelTankBlockEntity::updateConnectivity;
|
||||
withBlockEntityDo(world, pos, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,17 +111,6 @@ public class SteelTankBlock extends Block implements IWrenchable, IBE<SteelTankB
|
||||
p_206840_1_.add(TOP, BOTTOM, SHAPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightEmission(BlockState state, BlockGetter world, BlockPos pos) {
|
||||
SteelTankBlockEntity tankAt = ConnectivityHandler.partAt(getBlockEntityType(), world, pos);
|
||||
if (tankAt == null)
|
||||
return 0;
|
||||
SteelTankBlockEntity controllerTE = (SteelTankBlockEntity) tankAt.getControllerBE();
|
||||
if (controllerTE == null || !controllerTE.window)
|
||||
return 0;
|
||||
return tankAt.luminosity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult onWrenched(BlockState state, UseOnContext context) {
|
||||
withBlockEntityDo(context.getLevel(), context.getClickedPos(), SteelTankBlockEntity::toggleWindows);
|
||||
@@ -110,149 +119,143 @@ public class SteelTankBlock extends Block implements IWrenchable, IBE<SteelTankB
|
||||
|
||||
static final VoxelShape CAMPFIRE_SMOKE_CLIP = Block.box(0, 4, 0, 16, 16, 16);
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos,
|
||||
CollisionContext pContext) {
|
||||
if (pContext == CollisionContext.empty())
|
||||
return CAMPFIRE_SMOKE_CLIP;
|
||||
return pState.getShape(pLevel, pPos);
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos,
|
||||
CollisionContext pContext) {
|
||||
if (pContext == CollisionContext.empty())
|
||||
return CAMPFIRE_SMOKE_CLIP;
|
||||
return pState.getShape(pLevel, pPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getBlockSupportShape(BlockState pState, BlockGetter pReader, BlockPos pPos) {
|
||||
return Shapes.block();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState updateShape(BlockState pState, Direction pDirection, BlockState pNeighborState,
|
||||
LevelAccessor pLevel, BlockPos pCurrentPos, BlockPos pNeighborPos) {
|
||||
if (pDirection == Direction.DOWN && pNeighborState.getBlock() != this)
|
||||
withBlockEntityDo(pLevel, pCurrentPos, FluidTankBlockEntity::updateBoilerTemperature);
|
||||
return pState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
||||
BlockHitResult ray) {
|
||||
ItemStack heldItem = player.getItemInHand(hand);
|
||||
boolean onClient = world.isClientSide;
|
||||
|
||||
if (heldItem.isEmpty())
|
||||
return InteractionResult.PASS;
|
||||
if (!player.isCreative())
|
||||
return InteractionResult.PASS;
|
||||
|
||||
FluidExchange exchange = null;
|
||||
SteelTankBlockEntity be = ConnectivityHandler.partAt(getBlockEntityType(), world, pos);
|
||||
if (be == null)
|
||||
return InteractionResult.FAIL;
|
||||
|
||||
Direction direction = ray.getDirection();
|
||||
Storage<FluidVariant> fluidTank = be.getFluidStorage(direction);
|
||||
if (fluidTank == null)
|
||||
return InteractionResult.PASS;
|
||||
|
||||
FluidStack prevFluidInTank = TransferUtil.firstCopyOrEmpty(fluidTank);
|
||||
|
||||
if (FluidHelper.tryEmptyItemIntoBE(world, player, hand, heldItem, be, direction))
|
||||
exchange = FluidExchange.ITEM_TO_TANK;
|
||||
else if (FluidHelper.tryFillItemFromBE(world, player, hand, heldItem, be, direction))
|
||||
exchange = FluidExchange.TANK_TO_ITEM;
|
||||
|
||||
if (exchange == null) {
|
||||
if (GenericItemEmptying.canItemBeEmptied(world, heldItem)
|
||||
|| GenericItemFilling.canItemBeFilled(world, heldItem))
|
||||
return InteractionResult.SUCCESS;
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getBlockSupportShape(BlockState pState, BlockGetter pReader, BlockPos pPos) {
|
||||
return Shapes.block();
|
||||
SoundEvent soundevent = null;
|
||||
BlockState fluidState = null;
|
||||
FluidStack fluidInTank = TransferUtil.firstOrEmpty(fluidTank);
|
||||
|
||||
if (exchange == FluidExchange.ITEM_TO_TANK) {
|
||||
Fluid fluid = fluidInTank.getFluid();
|
||||
fluidState = fluid.defaultFluidState()
|
||||
.createLegacyBlock();
|
||||
soundevent = FluidVariantAttributes.getEmptySound(FluidVariant.of(fluid));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState updateShape(BlockState pState, Direction pDirection, BlockState pNeighborState,
|
||||
LevelAccessor pLevel, BlockPos pCurrentPos, BlockPos pNeighborPos) {
|
||||
if (pDirection == Direction.DOWN && pNeighborState.getBlock() != this)
|
||||
withBlockEntityDo(pLevel, pCurrentPos, SteelTankBlockEntity::updateBoilerTemperature);
|
||||
return pState;
|
||||
if (exchange == FluidExchange.TANK_TO_ITEM) {
|
||||
Fluid fluid = prevFluidInTank.getFluid();
|
||||
fluidState = fluid.defaultFluidState()
|
||||
.createLegacyBlock();
|
||||
soundevent = FluidVariantAttributes.getFillSound(FluidVariant.of(fluid));
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
||||
BlockHitResult ray) {
|
||||
ItemStack heldItem = player.getItemInHand(hand);
|
||||
boolean onClient = world.isClientSide;
|
||||
if (soundevent != null && !onClient) {
|
||||
float pitch = Mth
|
||||
.clamp(1 - (1f * fluidInTank.getAmount() / (FluidTankBlockEntity.getCapacityMultiplier() * 16)), 0, 1);
|
||||
pitch /= 1.5f;
|
||||
pitch += .5f;
|
||||
pitch += (world.random.nextFloat() - .5f) / 4f;
|
||||
world.playSound(null, pos, soundevent, SoundSource.BLOCKS, .5f, pitch);
|
||||
}
|
||||
|
||||
if (heldItem.isEmpty())
|
||||
return InteractionResult.PASS;
|
||||
if (!player.isCreative() && !creative)
|
||||
return InteractionResult.PASS;
|
||||
if (!fluidInTank.isFluidEqual(prevFluidInTank)) {
|
||||
if (be instanceof SteelTankBlockEntity) {
|
||||
SteelTankBlockEntity controllerBE = be.getControllerBE();
|
||||
if (controllerBE != null) {
|
||||
if (fluidState != null && onClient) {
|
||||
BlockParticleOption blockParticleData =
|
||||
new BlockParticleOption(ParticleTypes.BLOCK, fluidState);
|
||||
float level = (float) fluidInTank.getAmount() / TransferUtil.firstCapacity(fluidTank);
|
||||
|
||||
FluidExchange exchange = null;
|
||||
SteelTankBlockEntity te = ConnectivityHandler.partAt(getBlockEntityType(), world, pos);
|
||||
if (te == null)
|
||||
return InteractionResult.FAIL;
|
||||
boolean reversed = FluidVariantAttributes.isLighterThanAir(fluidInTank.getType());
|
||||
if (reversed)
|
||||
level = 1 - level;
|
||||
|
||||
LazyOptional<IFluidHandler> tankCapability = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY);
|
||||
if (!tankCapability.isPresent())
|
||||
return InteractionResult.PASS;
|
||||
IFluidHandler fluidTank = tankCapability.orElse(null);
|
||||
FluidStack prevFluidInTank = fluidTank.getFluidInTank(0)
|
||||
.copy();
|
||||
|
||||
if (FluidHelper.tryEmptyItemIntoBE(world, player, hand, heldItem, te))
|
||||
exchange = FluidExchange.ITEM_TO_TANK;
|
||||
else if (FluidHelper.tryFillItemFromBE(world, player, hand, heldItem, te))
|
||||
exchange = FluidExchange.TANK_TO_ITEM;
|
||||
|
||||
if (exchange == null) {
|
||||
if (GenericItemEmptying.canItemBeEmptied(world, heldItem)
|
||||
|| GenericItemFilling.canItemBeFilled(world, heldItem))
|
||||
return InteractionResult.SUCCESS;
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
SoundEvent soundevent = null;
|
||||
BlockState fluidState = null;
|
||||
FluidStack fluidInTank = tankCapability.map(fh -> fh.getFluidInTank(0))
|
||||
.orElse(FluidStack.EMPTY);
|
||||
|
||||
if (exchange == FluidExchange.ITEM_TO_TANK) {
|
||||
|
||||
|
||||
Fluid fluid = fluidInTank.getFluid();
|
||||
fluidState = fluid.defaultFluidState()
|
||||
.createLegacyBlock();
|
||||
soundevent = FluidHelper.getEmptySound(fluidInTank);
|
||||
}
|
||||
|
||||
if (exchange == FluidExchange.TANK_TO_ITEM) {
|
||||
|
||||
Fluid fluid = prevFluidInTank.getFluid();
|
||||
fluidState = fluid.defaultFluidState()
|
||||
.createLegacyBlock();
|
||||
soundevent = FluidHelper.getFillSound(prevFluidInTank);
|
||||
}
|
||||
|
||||
if (soundevent != null && !onClient) {
|
||||
float pitch = Mth
|
||||
.clamp(1 - (1f * fluidInTank.getAmount() / (SteelTankBlockEntity.getCapacityMultiplier() * 16)), 0, 1);
|
||||
pitch /= 1.5f;
|
||||
pitch += .5f;
|
||||
pitch += (world.random.nextFloat() - .5f) / 4f;
|
||||
world.playSound(null, pos, soundevent, SoundSource.BLOCKS, .5f, pitch);
|
||||
}
|
||||
|
||||
if (!fluidInTank.isFluidStackIdentical(prevFluidInTank)) {
|
||||
if (te instanceof SteelTankBlockEntity) {
|
||||
SteelTankBlockEntity controllerTE = (SteelTankBlockEntity) ((SteelTankBlockEntity) te).getControllerBE();
|
||||
if (controllerTE != null) {
|
||||
if (fluidState != null && onClient) {
|
||||
BlockParticleOption blockParticleData =
|
||||
new BlockParticleOption(ParticleTypes.BLOCK, fluidState);
|
||||
float level = (float) fluidInTank.getAmount() / fluidTank.getTankCapacity(0);
|
||||
|
||||
boolean reversed = fluidInTank.getFluid()
|
||||
.getFluidType()
|
||||
.isLighterThanAir();
|
||||
if (reversed)
|
||||
level = 1 - level;
|
||||
|
||||
Vec3 vec = ray.getLocation();
|
||||
vec = new Vec3(vec.x, controllerTE.getBlockPos()
|
||||
.getY() + level * (controllerTE.height - .5f) + .25f, vec.z);
|
||||
Vec3 motion = player.position()
|
||||
.subtract(vec)
|
||||
.scale(1 / 20f);
|
||||
vec = vec.add(motion);
|
||||
world.addParticle(blockParticleData, vec.x, vec.y, vec.z, motion.x, motion.y, motion.z);
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
controllerTE.sendDataImmediately();
|
||||
controllerTE.setChanged();
|
||||
Vec3 vec = ray.getLocation();
|
||||
vec = new Vec3(vec.x, controllerBE.getBlockPos()
|
||||
.getY() + level * (controllerBE.height - .5f) + .25f, vec.z);
|
||||
Vec3 motion = player.position()
|
||||
.subtract(vec)
|
||||
.scale(1 / 20f);
|
||||
vec = vec.add(motion);
|
||||
world.addParticle(blockParticleData, vec.x, vec.y, vec.z, motion.x, motion.y, motion.z);
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
controllerBE.sendDataImmediately();
|
||||
controllerBE.setChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.hasBlockEntity() && (state.getBlock() != newState.getBlock() || !newState.hasBlockEntity())) {
|
||||
BlockEntity te = world.getBlockEntity(pos);
|
||||
if (!(te instanceof SteelTankBlockEntity))
|
||||
return;
|
||||
SteelTankBlockEntity tankTE = (SteelTankBlockEntity) te;
|
||||
world.removeBlockEntity(pos);
|
||||
ConnectivityHandler.splitMulti(tankTE);
|
||||
}
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<SteelTankBlockEntity> getBlockEntityClass() {
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.hasBlockEntity() && (state.getBlock() != newState.getBlock() || !newState.hasBlockEntity())) {
|
||||
BlockEntity be = world.getBlockEntity(pos);
|
||||
if (!(be instanceof FluidTankBlockEntity))
|
||||
return;
|
||||
FluidTankBlockEntity tankBE = (FluidTankBlockEntity) be;
|
||||
world.removeBlockEntity(pos);
|
||||
ConnectivityHandler.splitMulti(tankBE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<SteelTankBlockEntity> getBlockEntityClass() {
|
||||
return SteelTankBlockEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends SteelTankBlockEntity> getBlockEntityType() {
|
||||
return creative ? TFMGBlockEntities.STEEL_FLUID_TANK.get() : TFMGBlockEntities.STEEL_FLUID_TANK.get();
|
||||
}
|
||||
@Override
|
||||
public BlockEntityType<? extends SteelTankBlockEntity> getBlockEntityType() {
|
||||
return TFMGBlockEntities.STEEL_FLUID_TANK.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState mirror(BlockState state, Mirror mirror) {
|
||||
@@ -304,15 +307,10 @@ public class SteelTankBlock extends Block implements IWrenchable, IBE<SteelTankB
|
||||
}
|
||||
}
|
||||
|
||||
// Tanks are less noisy when placed in batch
|
||||
public static final SoundType SILENCED_METAL =
|
||||
new ForgeSoundType(0.1F, 1.5F, () -> SoundEvents.METAL_BREAK, () -> SoundEvents.METAL_STEP,
|
||||
() -> SoundEvents.METAL_PLACE, () -> SoundEvents.METAL_HIT, () -> SoundEvents.METAL_FALL);
|
||||
|
||||
@Override
|
||||
public SoundType getSoundType(BlockState state, LevelReader world, BlockPos pos, Entity entity) {
|
||||
SoundType soundType = super.getSoundType(state, world, pos, entity);
|
||||
if (entity != null && entity.getPersistentData()
|
||||
SoundType soundType = getSoundType(state);
|
||||
if (entity != null && entity.getExtraCustomData()
|
||||
.contains("SilenceTankSound"))
|
||||
return SILENCED_METAL;
|
||||
return soundType;
|
||||
|
||||
@@ -13,10 +13,13 @@ import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
|
||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
|
||||
import com.simibubi.create.infrastructure.config.AllConfigs;
|
||||
import io.github.fabricators_of_create.porting_lib.transfer.TransferUtil;
|
||||
import io.github.fabricators_of_create.porting_lib.transfer.fluid.FluidTank;
|
||||
import io.github.fabricators_of_create.porting_lib.util.FluidStack;
|
||||
import io.github.fabricators_of_create.porting_lib.util.LazyOptional;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariantAttributeHandler;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariantAttributes;
|
||||
import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction;
|
||||
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -147,14 +150,14 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
removeController(true);
|
||||
lastKnownPos = worldPosition;
|
||||
}
|
||||
|
||||
protected void onFluidStackChanged(FluidStack newFluidStack) {
|
||||
if (!hasLevel())
|
||||
return;
|
||||
|
||||
FluidVariant attributes = newFluidStack.getType();
|
||||
int luminosity = (int) (attributes.getLightLevel(newFluidStack) / 1.2f);
|
||||
boolean reversed = attributes.isLighterThanAir();
|
||||
FluidVariantAttributeHandler handler = FluidVariantAttributes.getHandlerOrDefault(newFluidStack.getFluid());
|
||||
FluidVariant variant = newFluidStack.getType();
|
||||
int luminosity = (int) (handler.getLuminance(variant) / 1.2f);
|
||||
boolean reversed = handler.isLighterThanAir(variant);
|
||||
int maxY = (int) ((getFillState() * height) + 1);
|
||||
|
||||
for (int yOffset = 0; yOffset < height; yOffset++) {
|
||||
@@ -446,17 +449,14 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
|
||||
@Override
|
||||
public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
|
||||
SteelTankBlockEntity controllerTE = getControllerBE();
|
||||
SteelTankBlockEntity controllerBE = getControllerBE();
|
||||
|
||||
if(isDistillationTower)
|
||||
if (isDistillationTower)
|
||||
return false;
|
||||
|
||||
if(getControllerBE()!=null)
|
||||
if(getControllerBE().isDistillationTower)
|
||||
return false;
|
||||
|
||||
if (controllerBE != null && controllerBE.isDistillationTower)
|
||||
return true;
|
||||
return containedFluidTooltip(tooltip, isPlayerSneaking,
|
||||
controllerTE.getCapability(ForgeCapabilities.FLUID_HANDLER));
|
||||
controllerBE.getFluidStorage(null));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -486,7 +486,10 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
tankInventory.setCapacity(getTotalTankSize() * getCapacityMultiplier());
|
||||
tankInventory.readFromNBT(compound.getCompound("TankContent"));
|
||||
if (tankInventory.getSpace() < 0)
|
||||
tankInventory.drain(-tankInventory.getSpace(), FluidAction.EXECUTE);
|
||||
try (Transaction t = TransferUtil.getTransaction()) {
|
||||
tankInventory.extract(tankInventory.variant, -tankInventory.getSpace(), t);
|
||||
t.commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -578,7 +581,7 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
return MAX_SIZE;
|
||||
}
|
||||
|
||||
public static int getCapacityMultiplier() {
|
||||
public static long getCapacityMultiplier() {
|
||||
return AllConfigs.server().fluids.fluidTankCapacity.get() * 1000;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.drmangotea.createindustry.events;
|
||||
|
||||
import com.drmangotea.createindustry.CreateTFMGClient;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class ClientEvents {
|
||||
public static void onTick(Minecraft client) {
|
||||
CreateTFMGClient.ADVANCED_POTATO_CANNON_RENDER_HANDLER.tick();
|
||||
CreateTFMGClient.FLAMETHROWER_RENDER_HANDLER.tick();
|
||||
CreateTFMGClient.QUAD_POTATO_CANNON_RENDER_HANDLER.tick();
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
|
||||
ClientTickEvents.END_CLIENT_TICK.register(ClientEvents::onTick);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ import com.simibubi.create.content.equipment.zapper.ShootableGadgetItemMethods;
|
||||
import com.simibubi.create.foundation.item.CustomArmPoseItem;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.infrastructure.config.AllConfigs;
|
||||
import io.github.fabricators_of_create.porting_lib.item.EntitySwingListenerItem;
|
||||
import io.github.fabricators_of_create.porting_lib.item.ReequipAnimationItem;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -35,8 +37,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class AdvancedPotatoCannonItem extends ProjectileWeaponItem implements CustomArmPoseItem {
|
||||
|
||||
public class AdvancedPotatoCannonItem extends ProjectileWeaponItem implements CustomArmPoseItem,
|
||||
EntitySwingListenerItem, ReequipAnimationItem {
|
||||
public static ItemStack CLIENT_CURRENT_AMMO = ItemStack.EMPTY;
|
||||
public static final int MAX_DAMAGE = 500;
|
||||
|
||||
@@ -219,10 +221,6 @@ public class AdvancedPotatoCannonItem extends ProjectileWeaponItem implements Cu
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void initializeClient(Consumer<IClientItemExtensions> consumer) {
|
||||
consumer.accept(SimpleCustomRenderer.create(this, new AdvancedPotatoCannonItemRenderer()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class AdvancedPotatoCannonItemRenderer extends CustomRenderedItemModelRenderer {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void render(ItemStack stack, CustomRenderedItemModel model, PartialItemModelRenderer renderer,
|
||||
TransformType transformType, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.drmangotea.createindustry.base.util.spark.Spark;
|
||||
import com.drmangotea.createindustry.registry.TFMGCreativeModeTabs;
|
||||
import com.drmangotea.createindustry.registry.TFMGEntityTypes;
|
||||
import com.drmangotea.createindustry.registry.TFMGItems;
|
||||
import com.simibubi.create.content.equipment.potatoCannon.PotatoCannonItem;
|
||||
import com.simibubi.create.content.fluids.tank.FluidTankBlockEntity;
|
||||
import com.simibubi.create.foundation.item.CustomArmPoseItem;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
@@ -27,6 +28,8 @@ import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static com.drmangotea.createindustry.base.util.TFMGUtils.drain;
|
||||
|
||||
public class FlamethrowerItem extends Item implements CustomArmPoseItem {
|
||||
|
||||
|
||||
@@ -153,7 +156,7 @@ return Math.round( 13* ((float)((float)stack.getOrCreateTag().getInt("amount")/(
|
||||
long toDrain = Math.min(FUEL_CAPACITY - nbt.getInt("amount"), be.getFluid(0).getAmount());
|
||||
|
||||
nbt.putString("fuel", fluid);
|
||||
be.getTankInventory().drain(toDrain, IFluidHandler.FluidAction.EXECUTE);
|
||||
drain(be.getTankInventory(), toDrain);
|
||||
nbt.putLong("amount", nbt.getLong("amount") + toDrain);
|
||||
context.getPlayer().getCooldowns().addCooldown(stack.getItem(), 20);
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
import io.github.fabricators_of_create.porting_lib.enchant.CustomEnchantingBehaviorItem;
|
||||
import io.github.fabricators_of_create.porting_lib.item.EntitySwingListenerItem;
|
||||
import io.github.fabricators_of_create.porting_lib.item.ReequipAnimationItem;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.ChatFormatting;
|
||||
@@ -48,7 +51,8 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class QuadPotatoCannonItem extends ProjectileWeaponItem implements CustomArmPoseItem {
|
||||
public class QuadPotatoCannonItem extends ProjectileWeaponItem implements CustomArmPoseItem,
|
||||
CustomEnchantingBehaviorItem, ReequipAnimationItem, EntitySwingListenerItem {
|
||||
|
||||
public static ItemStack CLIENT_CURRENT_AMMO = ItemStack.EMPTY;
|
||||
public static final int MAX_DAMAGE = 100;
|
||||
@@ -74,7 +78,7 @@ public class QuadPotatoCannonItem extends ProjectileWeaponItem implements Custom
|
||||
return true;
|
||||
if (enchantment == AllEnchantments.POTATO_RECOVERY.get())
|
||||
return true;
|
||||
return super.canApplyAtEnchantingTable(stack, enchantment);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.simibubi.create.content.equipment.potatoCannon.PotatoCannonItem;
|
||||
import com.simibubi.create.content.equipment.potatoCannon.PotatoCannonItemRenderer;
|
||||
import com.simibubi.create.foundation.item.render.CustomRenderedItemModel;
|
||||
import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.render.PartialItemModelRenderer;
|
||||
|
||||
Reference in New Issue
Block a user