0.9.0
This commit is contained in:
@@ -1,15 +1,22 @@
|
||||
package com.drmangotea.createindustry;
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGContraptions;
|
||||
import com.drmangotea.createindustry.registry.TFMGContraptions;
|
||||
import com.drmangotea.createindustry.base.TFMGLangPartials;
|
||||
import com.drmangotea.createindustry.config.TFMGConfigs;
|
||||
import com.drmangotea.createindustry.items.gadgets.explosives.thermite_grenades.fire.TFMGColoredFires;
|
||||
import com.drmangotea.createindustry.items.weapons.explosives.thermite_grenades.fire.TFMGColoredFires;
|
||||
import com.drmangotea.createindustry.registry.*;
|
||||
import com.drmangotea.createindustry.worldgen.TFMGConfiguredFeatures;
|
||||
import com.drmangotea.createindustry.worldgen.TFMGFeatures;
|
||||
import com.drmangotea.createindustry.worldgen.TFMGOreConfigEntries;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import com.simibubi.create.AllParticleTypes;
|
||||
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock;
|
||||
import com.simibubi.create.foundation.data.CreateRegistrate;
|
||||
import com.simibubi.create.foundation.data.LangMerger;
|
||||
import com.simibubi.create.foundation.item.ItemDescription;
|
||||
import com.simibubi.create.foundation.item.KineticStats;
|
||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
||||
import com.simibubi.create.foundation.item.TooltipModifier;
|
||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.core.Holder;
|
||||
@@ -31,6 +38,8 @@ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import static com.simibubi.create.content.fluids.tank.BoilerHeaters.registerHeater;
|
||||
|
||||
|
||||
@Mod(CreateTFMG.MOD_ID)
|
||||
public class CreateTFMG
|
||||
@@ -41,8 +50,18 @@ public class CreateTFMG
|
||||
public static final CreateRegistrate REGISTRATE = CreateRegistrate.create(MOD_ID);
|
||||
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)));
|
||||
});
|
||||
}
|
||||
|
||||
public CreateTFMG()
|
||||
{
|
||||
|
||||
|
||||
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
|
||||
REGISTRATE.registerEventListeners(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
@@ -56,9 +75,16 @@ public class CreateTFMG
|
||||
TFMGEntityTypes.register();
|
||||
TFMGCreativeModeTabs.init();
|
||||
TFMGFluids.register();
|
||||
TFMGTags.init();
|
||||
TFMGPaletteBlocks.register();
|
||||
TFMGSoundEvents.prepare();
|
||||
TFMGContraptions.prepare();
|
||||
TFMGOreConfigEntries.init();
|
||||
TFMGParticleTypes.register(modEventBus);
|
||||
TFMGMobEffects.register(modEventBus);
|
||||
TFMGPotions.register(modEventBus);
|
||||
TFMGPackets.registerPackets();
|
||||
|
||||
|
||||
TFMGColoredFires.register(modEventBus);
|
||||
TFMGFeatures.register(modEventBus);
|
||||
@@ -67,6 +93,7 @@ public class CreateTFMG
|
||||
TFMGConfigs.register(ModLoadingContext.get());
|
||||
|
||||
//
|
||||
modEventBus.addListener(CreateTFMG::init);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
modEventBus.addListener(EventPriority.LOWEST, CreateTFMG::gatherData);
|
||||
modEventBus.addListener(TFMGSoundEvents::register);
|
||||
@@ -74,6 +101,28 @@ public class CreateTFMG
|
||||
modEventBus.addListener(this::clientSetup);
|
||||
|
||||
}
|
||||
|
||||
public static void init(final FMLCommonSetupEvent event) {
|
||||
TFMGFluids.registerFluidInteractions();
|
||||
|
||||
event.enqueueWork(() -> {
|
||||
|
||||
registerHeater(TFMGBlocks.FIREBOX.get(), (level, pos, state) -> {
|
||||
BlazeBurnerBlock.HeatLevel value = state.getValue(BlazeBurnerBlock.HEAT_LEVEL);
|
||||
if (value == BlazeBurnerBlock.HeatLevel.NONE) {
|
||||
return -1;
|
||||
}
|
||||
if (value == BlazeBurnerBlock.HeatLevel.SEETHING) {
|
||||
return 3;
|
||||
}
|
||||
if (value.isAtLeast(BlazeBurnerBlock.HeatLevel.FADING)) {
|
||||
return 2;
|
||||
}
|
||||
return -1;
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
@SuppressWarnings("removal")
|
||||
public static void gatherData(GatherDataEvent event) {
|
||||
DataGenerator gen = event.getGenerator();
|
||||
@@ -87,7 +136,7 @@ public class CreateTFMG
|
||||
private void commonSetup(final FMLCommonSetupEvent event) {
|
||||
event.enqueueWork(() -> {
|
||||
final Holder<PlacedFeature> initializeOil = TFMGConfiguredFeatures.OIL_PLACED;
|
||||
final Holder<PlacedFeature> initializeSimulatedOil = TFMGConfiguredFeatures.SIMULATED_OIL_PLACED;
|
||||
final Holder<PlacedFeature> initializeSimulatedOil = TFMGConfiguredFeatures.OIL_DEPOSIT_PLACED;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package com.drmangotea.createindustry;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.items.gadgets.quad_potato_cannon.QuadPotatoCannonRenderHandler;
|
||||
import com.drmangotea.createindustry.items.weapons.advanced_potato_cannon.AdvancedPotatoCannonRenderHandler;
|
||||
import com.drmangotea.createindustry.items.weapons.flamethrover.FlamethrowerRenderHandler;
|
||||
import com.drmangotea.createindustry.items.weapons.quad_potato_cannon.QuadPotatoCannonRenderHandler;
|
||||
import com.drmangotea.createindustry.ponder.TFMGPonderIndex;
|
||||
import com.drmangotea.createindustry.registry.TFMGPartialModels;
|
||||
import com.drmangotea.createindustry.registry.TFMGParticleTypes;
|
||||
import com.simibubi.create.AllParticleTypes;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
@@ -11,10 +16,23 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
public class CreateTFMGClient {
|
||||
public static final QuadPotatoCannonRenderHandler QUAD_POTATO_CANNON_RENDER_HANDLER = new QuadPotatoCannonRenderHandler();
|
||||
|
||||
public static final AdvancedPotatoCannonRenderHandler ADVANCED_POTATO_CANNON_RENDER_HANDLER = new AdvancedPotatoCannonRenderHandler();
|
||||
|
||||
public static final FlamethrowerRenderHandler FLAMETHROWER_RENDER_HANDLER = new FlamethrowerRenderHandler();
|
||||
|
||||
public CreateTFMGClient() {
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
IEventBus forgeEventBus = MinecraftForge.EVENT_BUS;
|
||||
TFMGPartialModels.init();
|
||||
modEventBus.addListener(TFMGParticleTypes::registerFactories);
|
||||
modEventBus.register(this);
|
||||
|
||||
|
||||
|
||||
ADVANCED_POTATO_CANNON_RENDER_HANDLER.registerListeners(forgeEventBus);
|
||||
QUAD_POTATO_CANNON_RENDER_HANDLER.registerListeners(forgeEventBus);
|
||||
FLAMETHROWER_RENDER_HANDLER.registerListeners(forgeEventBus);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.drmangotea.createindustry.CreateTFMG;
|
||||
import com.drmangotea.createindustry.blocks.decoration.doors.TFMGSlidingDoorBlock;
|
||||
import com.drmangotea.createindustry.blocks.encased.TFMGEncasedCogwheelBlock;
|
||||
import com.drmangotea.createindustry.blocks.encased.TFMGEncasedShaftBlock;
|
||||
import com.drmangotea.createindustry.blocks.electricity.cable_blocks.copycat_cable_block.CopycatCableBlock;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllTags;
|
||||
import com.simibubi.create.content.contraptions.behaviour.DoorMovingInteraction;
|
||||
@@ -13,22 +15,19 @@ import com.simibubi.create.content.kinetics.BlockStressDefaults;
|
||||
import com.simibubi.create.content.kinetics.base.RotatedPillarKineticBlock;
|
||||
import com.simibubi.create.content.kinetics.simpleRelays.encased.EncasedCogCTBehaviour;
|
||||
import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry;
|
||||
import com.simibubi.create.foundation.data.AssetLookup;
|
||||
import com.simibubi.create.foundation.data.CreateRegistrate;
|
||||
import com.simibubi.create.foundation.data.ModelGen;
|
||||
import com.simibubi.create.foundation.data.SharedProperties;
|
||||
import com.simibubi.create.foundation.data.*;
|
||||
import com.tterrag.registrate.builders.BlockBuilder;
|
||||
import com.tterrag.registrate.util.nullness.NonNullUnaryOperator;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.data.loot.BlockLoot;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraftforge.client.model.generators.ModelFile;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
@@ -38,7 +37,7 @@ import static com.simibubi.create.AllMovementBehaviours.movementBehaviour;
|
||||
import static com.simibubi.create.foundation.data.BlockStateGen.axisBlock;
|
||||
import static com.simibubi.create.foundation.data.TagGen.pickaxeOnly;
|
||||
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public class TFMGBuilderTransformers {
|
||||
|
||||
public static <B extends TFMGSlidingDoorBlock, P> NonNullUnaryOperator<BlockBuilder<B, P>> slidingDoor(String type) {
|
||||
@@ -77,7 +76,7 @@ public class TFMGBuilderTransformers {
|
||||
|
||||
public static <B extends TFMGEncasedShaftBlock, P> NonNullUnaryOperator<BlockBuilder<B, P>> encasedShaft(String casing,
|
||||
Supplier<CTSpriteShiftEntry> casingShift) {
|
||||
return builder -> encasedBase(builder, () -> AllBlocks.SHAFT.get())
|
||||
return builder -> encasedBase(builder, () -> TFMGBlocks.NEON_TUBE.get())
|
||||
.onRegister(CreateRegistrate.connectedTextures(() -> new EncasedCTBehaviour(casingShift.get())))
|
||||
.onRegister(CreateRegistrate.casingConnectivity((block, cc) -> cc.make(block, casingShift.get(),
|
||||
(s, f) -> f.getAxis() != s.getValue(TFMGEncasedShaftBlock.AXIS))))
|
||||
@@ -144,4 +143,19 @@ public class TFMGBuilderTransformers {
|
||||
}
|
||||
|
||||
|
||||
public static <B extends CopycatCableBlock, P> NonNullUnaryOperator<BlockBuilder<B, P>> copycatCable() {
|
||||
return b -> b.initialProperties(SharedProperties::softMetal)
|
||||
.blockstate((c, p) -> p.simpleBlock(c.get(), p.models()
|
||||
.getExistingFile(p.mcLoc("air"))))
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.properties(p -> p.noOcclusion()
|
||||
.color(MaterialColor.NONE))
|
||||
.addLayer(() -> RenderType::solid)
|
||||
.addLayer(() -> RenderType::cutout)
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
// .addLayer(() -> RenderType::translucent)
|
||||
.color(() -> CopycatCableBlock::wrappedColor)
|
||||
.transform(TagGen.axeOrPickaxe());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
public enum TFMGLangPartials implements LangPartial {
|
||||
INTERFACE("UI & Messages"),
|
||||
|
||||
TOOLTIPS("Tooltips"),
|
||||
PONDERS("Ponders");
|
||||
|
||||
;
|
||||
|
||||
@@ -10,18 +10,36 @@ public class TFMGSpriteShifts {
|
||||
|
||||
public static final CTSpriteShiftEntry
|
||||
CAST_IRON_BLOCK = omni("cast_iron_block"),
|
||||
|
||||
LEAD_BLOCK = omni("lead_block"),
|
||||
STEEL_BLOCK = omni("steel_block");
|
||||
public static final CTSpriteShiftEntry
|
||||
LEAD_GLASS = omni("lead_glass"),
|
||||
STEEL_CASING = omni("steel_casing");
|
||||
|
||||
|
||||
public static final CTSpriteShiftEntry STEEL_SCAFFOLD = horizontal("scaffold/steel_scaffold"),
|
||||
public static final CTSpriteShiftEntry
|
||||
STEEL_SCAFFOLD = horizontal("scaffold/steel_scaffold"),
|
||||
ALUMINUM_SCAFFOLD = horizontal("scaffold/aluminum_scaffold");
|
||||
public static final CTSpriteShiftEntry
|
||||
ALUMINUM_SCAFFOLD_TOP = omni("aluminum_casing");
|
||||
|
||||
|
||||
public static final CTSpriteShiftEntry
|
||||
HEAVY_MACHINERY_CASING = omni("heavy_machinery_casing");
|
||||
STEEL_SCAFFOLD_INSIDE = horizontal("scaffold/steel_scaffold_inside"),
|
||||
ALUMINUM_SCAFFOLD_INSIDE = horizontal("scaffold/aluminum_scaffold_inside"),
|
||||
|
||||
CAST_IRON_SCAFFOLD_INSIDE = horizontal("scaffold/cast_iron_scaffold_inside"),
|
||||
|
||||
LEAD_SCAFFOLD_INSIDE = horizontal("scaffold/lead_scaffold_inside"),
|
||||
|
||||
NICKEL_SCAFFOLD_INSIDE = horizontal("scaffold/nickel_scaffold_inside")
|
||||
|
||||
;
|
||||
|
||||
public static final CTSpriteShiftEntry
|
||||
HEAVY_MACHINERY_CASING = omni("heavy_machinery_casing"),
|
||||
ELECTRIC_CASING = omni("electric_casing");
|
||||
|
||||
public static final CTSpriteShiftEntry
|
||||
STEEL_FLUID_TANK = getCT(AllCTTypes.RECTANGLE, "steel_fluid_tank"),
|
||||
@@ -31,8 +49,7 @@ public class TFMGSpriteShifts {
|
||||
public static final CTSpriteShiftEntry
|
||||
STEEL_SHEETMETAL = getCT(AllCTTypes.RECTANGLE, "steel_sheetmetal");
|
||||
|
||||
public static final CTSpriteShiftEntry STEEL_SCAFFOLD_INSIDE = horizontal("scaffold/steel_scaffold_inside"),
|
||||
ALUMINUM_SCAFFOLD_INSIDE = horizontal("scaffold/aluminum_scaffold_inside");
|
||||
|
||||
|
||||
|
||||
public static final CTSpriteShiftEntry
|
||||
@@ -41,6 +58,10 @@ public class TFMGSpriteShifts {
|
||||
COKE_OVEN_BACK = getCT(AllCTTypes.RECTANGLE, "coke_oven/side"),
|
||||
COKE_OVEN_SIDE = getCT(AllCTTypes.RECTANGLE, "coke_oven/side");
|
||||
|
||||
public static final CTSpriteShiftEntry
|
||||
CAPACITOR = getCT(AllCTTypes.RECTANGLE, "capacitor_side"),
|
||||
ACCUMULATOR = getCT(AllCTTypes.RECTANGLE, "accumulator_side");
|
||||
|
||||
|
||||
public static final CTSpriteShiftEntry
|
||||
STEEL_ENCASED_COGWHEEL_SIDE = vertical("steel_encased_cogwheel_side"),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.drmangotea.createindustry.base.spark;
|
||||
package com.drmangotea.createindustry.base.util.spark;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.items.gadgets.explosives.thermite_grenades.fire.BlueFireBlock;
|
||||
import com.drmangotea.createindustry.items.weapons.explosives.thermite_grenades.fire.BlueFireBlock;
|
||||
import com.drmangotea.createindustry.registry.TFMGEntityTypes;
|
||||
import com.drmangotea.createindustry.registry.TFMGItems;
|
||||
import com.simibubi.create.content.trains.CubeParticleData;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.base.spark;
|
||||
package com.drmangotea.createindustry.base.util.spark;
|
||||
|
||||
import com.drmangotea.createindustry.CreateTFMG;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.drmangotea.createindustry.base.spark;
|
||||
package com.drmangotea.createindustry.base.util.spark;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.items.gadgets.explosives.thermite_grenades.fire.GreenFireBlock;
|
||||
import com.drmangotea.createindustry.items.weapons.explosives.thermite_grenades.fire.GreenFireBlock;
|
||||
import com.drmangotea.createindustry.registry.TFMGEntityTypes;
|
||||
import com.drmangotea.createindustry.registry.TFMGItems;
|
||||
import com.simibubi.create.content.trains.CubeParticleData;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.base.spark;
|
||||
package com.drmangotea.createindustry.base.util.spark;
|
||||
|
||||
import com.drmangotea.createindustry.CreateTFMG;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.base.spark;
|
||||
package com.drmangotea.createindustry.base.util.spark;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGEntityTypes;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.base.spark;
|
||||
package com.drmangotea.createindustry.base.util.spark;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.blocks.decoration.flywheels;
|
||||
package com.drmangotea.createindustry.blocks.decoration.kinetics.flywheels;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.blocks.decoration.flywheels;
|
||||
package com.drmangotea.createindustry.blocks.decoration.kinetics.flywheels;
|
||||
|
||||
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
|
||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.blocks.decoration.flywheels;
|
||||
package com.drmangotea.createindustry.blocks.decoration.kinetics.flywheels;
|
||||
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.jozufozu.flywheel.api.instance.DynamicInstance;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.blocks.decoration.flywheels;
|
||||
package com.drmangotea.createindustry.blocks.decoration.kinetics.flywheels;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
@@ -7,19 +7,11 @@ import com.simibubi.create.foundation.block.IBE;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
||||
public class FluidDepositBlock extends Block implements IBE<FluidDepositBlockEntity> {
|
||||
public class FluidDepositBlock extends Block {
|
||||
|
||||
public FluidDepositBlock(Properties p_49795_) {
|
||||
super(p_49795_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<FluidDepositBlockEntity> getBlockEntityClass() {
|
||||
return FluidDepositBlockEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends FluidDepositBlockEntity> getBlockEntityType() {
|
||||
return TFMGBlockEntities.OIL_DEPOSIT.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.drmangotea.createindustry.blocks.deposits;
|
||||
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.CreateTFMG;
|
||||
import com.drmangotea.createindustry.registry.TFMGFluids;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FluidDepositBlockEntity extends SmartBlockEntity {
|
||||
|
||||
public final int baseFluidAmount= Create.RANDOM.nextInt(3000000);
|
||||
public final int fluidAmountToBuckets =baseFluidAmount/1000;
|
||||
public int fluidAmount= fluidAmountToBuckets;
|
||||
|
||||
public FluidDepositBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(CompoundTag compound, boolean clientPacket) {
|
||||
|
||||
compound.putInt("FluidAmount", baseFluidAmount);
|
||||
|
||||
super.write(compound, clientPacket);
|
||||
|
||||
}
|
||||
@Override
|
||||
protected void read(CompoundTag compound, boolean clientPacket) {
|
||||
super.read(compound, clientPacket);
|
||||
|
||||
|
||||
fluidAmount = compound.getInt("FluidAmount");
|
||||
|
||||
}
|
||||
public Fluid getDepositFluid(){
|
||||
return TFMGFluids.CRUDE_OIL.getSource();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.drmangotea.createindustry.blocks.deposits.surface_scanner;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.blocks.deposits.FluidDepositBlockEntity;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.content.equipment.wrench.IWrenchable;
|
||||
@@ -23,7 +23,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import java.util.List;
|
||||
|
||||
public class SurfaceScannerBlockEntity extends KineticBlockEntity implements IHaveGoggleInformation, IWrenchable {
|
||||
public FluidDepositBlockEntity deposit;
|
||||
public BlockPos deposit;
|
||||
public BlockPos checkedPosition;
|
||||
public boolean foundDeposit=false;
|
||||
public BlockPos depositPos;
|
||||
@@ -98,11 +98,11 @@ public class SurfaceScannerBlockEntity extends KineticBlockEntity implements IHa
|
||||
float xDistance;
|
||||
|
||||
|
||||
zDistance = deposit.getBlockPos().getZ()-getBlockPos().getZ();
|
||||
zDistance = deposit.getZ()-getBlockPos().getZ();
|
||||
|
||||
|
||||
|
||||
xDistance = deposit.getBlockPos().getX()-getBlockPos().getX();
|
||||
xDistance = deposit.getX()-getBlockPos().getX();
|
||||
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ public class SurfaceScannerBlockEntity extends KineticBlockEntity implements IHa
|
||||
|
||||
angle = (float) Math.toDegrees(Math.atan(xDistance/zDistance));
|
||||
|
||||
if(this.getBlockPos().getZ()<deposit.getBlockPos().getZ())
|
||||
if(this.getBlockPos().getZ()<deposit.getZ())
|
||||
{
|
||||
angle +=180;
|
||||
}
|
||||
@@ -142,15 +142,15 @@ public class SurfaceScannerBlockEntity extends KineticBlockEntity implements IHa
|
||||
int random2 = Create.RANDOM.nextInt(2);
|
||||
for(int x = 0; x<2;x++)
|
||||
checkedPosition = new BlockPos(this.getBlockPos().getX() + random, -63-random2, this.getBlockPos().getZ() + random1);
|
||||
BlockEntity checkedTileEntity = level.getBlockEntity(checkedPosition);
|
||||
if (checkedTileEntity instanceof FluidDepositBlockEntity) {
|
||||
deposit = (FluidDepositBlockEntity) checkedTileEntity;
|
||||
BlockState checkedState = level.getBlockState(checkedPosition);
|
||||
if (checkedState.is(TFMGBlocks.OIL_DEPOSIT.get())) {
|
||||
deposit = checkedPosition;
|
||||
if(level.getBlockState(checkedPosition.above()) != Blocks.BEDROCK.defaultBlockState()&&
|
||||
level.getBlockState(checkedPosition.above(2)) != Blocks.BEDROCK.defaultBlockState()
|
||||
&& level.getBlockState(checkedPosition.above(3)) != Blocks.BEDROCK.defaultBlockState()
|
||||
&& level.getBlockState(checkedPosition.above(4)) != Blocks.BEDROCK.defaultBlockState())
|
||||
foundDeposit = true;
|
||||
depositPos = deposit.getBlockPos();
|
||||
depositPos = deposit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.drmangotea.createindustry.blocks.encased;
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.simibubi.create.AllBlockEntityTypes;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.contraptions.ITransformableBlock;
|
||||
@@ -17,6 +18,9 @@ import com.simibubi.create.content.schematics.requirement.ItemRequirement;
|
||||
import com.simibubi.create.foundation.block.IBE;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.VoxelShaper;
|
||||
import com.tterrag.registrate.util.entry.BlockEntityEntry;
|
||||
import com.tterrag.registrate.util.entry.BlockEntry;
|
||||
import com.tterrag.registrate.util.entry.ItemEntry;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -52,8 +56,39 @@ public class TFMGEncasedCogwheelBlock extends RotatedPillarKineticBlock
|
||||
protected final boolean isLarge;
|
||||
private final Supplier<Block> casing;
|
||||
|
||||
public TFMGEncasedCogwheelBlock(Properties properties, boolean large, Supplier<Block> casing) {
|
||||
private final BlockEntry<?> blockSmall;
|
||||
|
||||
private final BlockEntry<?> blockLarge;
|
||||
|
||||
private final BlockEntityEntry<SimpleKineticBlockEntity> beSmall;
|
||||
private final BlockEntityEntry<SimpleKineticBlockEntity> beLarge;
|
||||
|
||||
|
||||
|
||||
|
||||
public static TFMGEncasedCogwheelBlock regular(Properties properties, boolean large, Supplier<Block> casing){
|
||||
return new TFMGEncasedCogwheelBlock(properties,large,casing, AllBlocks.COGWHEEL,AllBlocks.LARGE_COGWHEEL,TFMGBlockEntities.TFMG_ENCASED_COGWHEEL,TFMGBlockEntities.TFMG_ENCASED_LARGE_COGWHEEL);
|
||||
}
|
||||
public static TFMGEncasedCogwheelBlock steel(Properties properties, boolean large, Supplier<Block> casing){
|
||||
return new TFMGEncasedCogwheelBlock(properties,large,casing, TFMGBlocks.STEEL_COGWHEEL,TFMGBlocks.LARGE_STEEL_COGWHEEL,TFMGBlockEntities.ENCASED_STEEL_COGWHEEL,TFMGBlockEntities.ENCASED_LARGE_STEEL_COGWHEEL);
|
||||
}
|
||||
public static TFMGEncasedCogwheelBlock aluminum(Properties properties, boolean large, Supplier<Block> casing){
|
||||
return new TFMGEncasedCogwheelBlock(properties,large,casing, TFMGBlocks.ALUMINUM_COGWHEEL,TFMGBlocks.LARGE_ALUMINUM_COGWHEEL,TFMGBlockEntities.ENCASED_ALUMINUM_COGWHEEL,TFMGBlockEntities.ENCASED_LARGE_ALUMINUM_COGWHEEL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public TFMGEncasedCogwheelBlock(Properties properties, boolean large, Supplier<Block> casing, BlockEntry<?> blockSmall, BlockEntry<?> blockLarge,BlockEntityEntry<SimpleKineticBlockEntity> beSmall,BlockEntityEntry<SimpleKineticBlockEntity> beLarge) {
|
||||
super(properties);
|
||||
|
||||
this.beSmall = beSmall;
|
||||
this.beLarge = beLarge;
|
||||
|
||||
this.blockSmall = blockSmall;
|
||||
this.blockLarge = blockLarge;
|
||||
|
||||
isLarge = large;
|
||||
this.casing = casing;
|
||||
registerDefaultState(defaultBlockState().setValue(TOP_SHAFT, false)
|
||||
@@ -73,7 +108,7 @@ public class TFMGEncasedCogwheelBlock extends RotatedPillarKineticBlock
|
||||
if (target instanceof BlockHitResult)
|
||||
return ((BlockHitResult) target).getDirection()
|
||||
.getAxis() != getRotationAxis(state)
|
||||
? isLarge ? AllBlocks.LARGE_COGWHEEL.asStack() : AllBlocks.COGWHEEL.asStack()
|
||||
? isLarge ? blockLarge.asStack() : blockSmall.asStack()
|
||||
: getCasing().asItem().getDefaultInstance();
|
||||
return super.getCloneItemStack(state, target, world, pos, player);
|
||||
}
|
||||
@@ -131,7 +166,7 @@ public class TFMGEncasedCogwheelBlock extends RotatedPillarKineticBlock
|
||||
context.getLevel()
|
||||
.levelEvent(2001, context.getClickedPos(), Block.getId(state));
|
||||
KineticBlockEntity.switchToBlockState(context.getLevel(), context.getClickedPos(),
|
||||
(isLarge ? AllBlocks.LARGE_COGWHEEL : AllBlocks.COGWHEEL).getDefaultState()
|
||||
(isLarge ? blockLarge : blockSmall).getDefaultState()
|
||||
.setValue(AXIS, state.getValue(AXIS)));
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
@@ -252,7 +287,7 @@ public class TFMGEncasedCogwheelBlock extends RotatedPillarKineticBlock
|
||||
@Override
|
||||
public ItemRequirement getRequiredItems(BlockState state, BlockEntity be) {
|
||||
return ItemRequirement
|
||||
.of(isLarge ? AllBlocks.LARGE_COGWHEEL.getDefaultState() : AllBlocks.COGWHEEL.getDefaultState(), be);
|
||||
.of(isLarge ? blockLarge.getDefaultState() : blockSmall.getDefaultState(), be);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -262,7 +297,7 @@ public class TFMGEncasedCogwheelBlock extends RotatedPillarKineticBlock
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends SimpleKineticBlockEntity> getBlockEntityType() {
|
||||
return isLarge ? TFMGBlockEntities.TFMG_ENCASED_LARGE_COGWHEEL.get() : TFMGBlockEntities.TFMG_ENCASED_COGWHEEL.get();
|
||||
return isLarge ? beLarge.get() : beSmall.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.drmangotea.createindustry.blocks.engines.compact;
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGFluids;
|
||||
import com.drmangotea.createindustry.registry.TFMGSoundEvents;
|
||||
import com.drmangotea.createindustry.registry.TFMGTags;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.content.equipment.wrench.IWrenchable;
|
||||
@@ -17,6 +18,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
@@ -29,10 +31,10 @@ import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
|
||||
@@ -72,8 +74,8 @@ public class CompactEngineBlockEntity extends GeneratingKineticBlockEntity imple
|
||||
public float powerModifier=1;
|
||||
public float efficiencyModifier = 1.4f;
|
||||
//
|
||||
int signal;
|
||||
boolean signalChanged;
|
||||
int signal;
|
||||
boolean signalChanged;
|
||||
//
|
||||
|
||||
// protected ScrollValueBehaviour generatedSpeed;
|
||||
@@ -123,6 +125,10 @@ boolean signalChanged;
|
||||
fuelConsumption = (int)((speed/(efficiency/10)/13)+1);
|
||||
if(fuelConsumption<1)
|
||||
fuelConsumption=0;
|
||||
|
||||
if(this.isOverStressed())
|
||||
fuelConsumption = 0;
|
||||
|
||||
if(!tankInventory.isEmpty()) {
|
||||
|
||||
if(consumptionTimer>=45) {
|
||||
@@ -223,7 +229,7 @@ boolean signalChanged;
|
||||
|
||||
|
||||
////////////////////////////////////////
|
||||
LazyOptional<IFluidHandler> handler = this.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY);
|
||||
LazyOptional<IFluidHandler> handler = this.getCapability(ForgeCapabilities.FLUID_HANDLER);
|
||||
Optional<IFluidHandler> resolve = handler.resolve();
|
||||
if (!resolve.isPresent())
|
||||
return false;
|
||||
@@ -372,7 +378,7 @@ public void write(CompoundTag compound, boolean clientPacket) {
|
||||
soundTimer++;
|
||||
|
||||
// if(!isExhaustTankFull()) {
|
||||
if (soundTimer >= ((16-signal)/0.8)+1) {
|
||||
if (soundTimer >= (((16-signal)/0.8)+1)/2) {
|
||||
if(signal!=0&&
|
||||
tankInventory.getFluidAmount()!=0 &&
|
||||
!overStressed
|
||||
@@ -448,7 +454,7 @@ public void write(CompoundTag compound, boolean clientPacket) {
|
||||
soundTimer=0;
|
||||
|
||||
|
||||
TFMGSoundEvents.ENGINE.playAt(level, worldPosition, 0.6f, 1f, false);
|
||||
TFMGSoundEvents.ENGINE.playAt(level, worldPosition, 0.04f, 1f, false);
|
||||
|
||||
|
||||
}
|
||||
@@ -483,7 +489,7 @@ public void write(CompoundTag compound, boolean clientPacket) {
|
||||
return new SmartFluidTank(1000, this::onFluidStackChanged){
|
||||
@Override
|
||||
public boolean isFluidValid(FluidStack stack) {
|
||||
return stack.getFluid().isSame(validFuel());
|
||||
return stack.getFluid().is(validFuel());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -516,7 +522,7 @@ public void write(CompoundTag compound, boolean clientPacket) {
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
|
||||
|
||||
if (cap == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
||||
if (cap == ForgeCapabilities.FLUID_HANDLER)
|
||||
return fluidCapability.cast();
|
||||
return super.getCapability(cap, side);
|
||||
}
|
||||
@@ -533,8 +539,8 @@ public void write(CompoundTag compound, boolean clientPacket) {
|
||||
return tankInventory;
|
||||
}
|
||||
|
||||
public Fluid validFuel(){
|
||||
return TFMGFluids.GASOLINE.get();
|
||||
public TagKey<Fluid> validFuel(){
|
||||
return TFMGTags.TFMGFluidTags.GASOLINE.tag;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.drmangotea.createindustry.blocks.engines.diesel.engine_expansion.Dies
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.drmangotea.createindustry.registry.TFMGFluids;
|
||||
import com.drmangotea.createindustry.registry.TFMGSoundEvents;
|
||||
import com.drmangotea.createindustry.registry.TFMGTags;
|
||||
import com.simibubi.create.content.contraptions.bearing.WindmillBearingBlockEntity;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.content.kinetics.base.GeneratingKineticBlockEntity;
|
||||
@@ -20,6 +21,7 @@ import com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollOp
|
||||
import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
|
||||
import com.simibubi.create.foundation.fluid.SmartFluidTank;
|
||||
import com.simibubi.create.foundation.utility.*;
|
||||
import mekanism.common.recipe.lookup.cache.type.FluidInputCache;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -27,6 +29,7 @@ import net.minecraft.core.Direction.Axis;
|
||||
import net.minecraft.core.Direction.AxisDirection;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -36,9 +39,9 @@ import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
@@ -86,7 +89,7 @@ public class DieselEngineBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
|
||||
|
||||
|
||||
fuelTank = createInventory(TFMGFluids.DIESEL.getSource(),false);
|
||||
fuelTank = createInventory(TFMGTags.TFMGFluidTags.DIESEL.tag, false);
|
||||
|
||||
|
||||
|
||||
@@ -130,10 +133,6 @@ public class DieselEngineBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(getBlockState().getValue(FACE)==AttachFace.WALL)
|
||||
expansionPos = this.getBlockPos().relative(getBlockState().getValue(FACING).getOpposite());
|
||||
if(getBlockState().getValue(FACE)==AttachFace.CEILING)
|
||||
@@ -498,7 +497,7 @@ public class DieselEngineBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
@SuppressWarnings("removal")
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, Direction side) {
|
||||
|
||||
if (cap == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
||||
if (cap == ForgeCapabilities.FLUID_HANDLER)
|
||||
return fluidCapability.cast();
|
||||
return super.getCapability(cap, side);
|
||||
}
|
||||
@@ -536,7 +535,7 @@ public class DieselEngineBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
|
||||
|
||||
//--Fluid Info--//
|
||||
LazyOptional<IFluidHandler> handler = this.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY);
|
||||
LazyOptional<IFluidHandler> handler = this.getCapability(ForgeCapabilities.FLUID_HANDLER);
|
||||
Optional<IFluidHandler> resolve = handler.resolve();
|
||||
if (!resolve.isPresent())
|
||||
return false;
|
||||
@@ -606,6 +605,33 @@ public class DieselEngineBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action) {
|
||||
if (!extractionAllowed)
|
||||
return FluidStack.EMPTY;
|
||||
return super.drain(resource, action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, FluidAction action) {
|
||||
if (!extractionAllowed)
|
||||
return FluidStack.EMPTY;
|
||||
return super.drain(maxDrain, action);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
protected SmartFluidTank createInventory(TagKey<Fluid> validFluid, boolean extractionAllowed) {
|
||||
return new SmartFluidTank(1000, this::onFluidStackChanged) {
|
||||
@Override
|
||||
public boolean isFluidValid(FluidStack stack) {
|
||||
|
||||
return stack.getFluid().is(validFluid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action) {
|
||||
if (!extractionAllowed)
|
||||
|
||||
@@ -28,11 +28,11 @@ public class DieselEngineInstance extends BlockEntityInstance<DieselEngineBlockE
|
||||
|
||||
piston = materialManager.defaultSolid()
|
||||
.material(Materials.TRANSFORMED)
|
||||
.getModel(AllPartialModels.ENGINE_PISTON, blockState)
|
||||
.getModel(TFMGPartialModels.DIESEL_ENGINE_PISTON, blockState)
|
||||
.createInstance();
|
||||
linkage = materialManager.defaultSolid()
|
||||
.material(Materials.TRANSFORMED)
|
||||
.getModel(AllPartialModels.ENGINE_LINKAGE, blockState)
|
||||
.getModel(TFMGPartialModels.DIESEL_ENGINE_LINKAGE, blockState)
|
||||
.createInstance();
|
||||
connector = materialManager.defaultSolid()
|
||||
.material(Materials.TRANSFORMED)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.drmangotea.createindustry.blocks.engines.diesel;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGPartialModels;
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
@@ -52,13 +53,13 @@ public class DieselEngineRenderer extends SafeBlockEntityRenderer<DieselEngineBl
|
||||
|
||||
|
||||
|
||||
transformed(AllPartialModels.ENGINE_PISTON, blockState, facing, roll90)
|
||||
transformed(TFMGPartialModels.DIESEL_ENGINE_PISTON, blockState, facing, roll90)
|
||||
.translate(0, piston, 0)
|
||||
.light(light)
|
||||
.renderInto(ms, vb);
|
||||
|
||||
|
||||
transformed(AllPartialModels.ENGINE_LINKAGE, blockState, facing, roll90)
|
||||
transformed(TFMGPartialModels.DIESEL_ENGINE_LINKAGE, blockState, facing, roll90)
|
||||
.centre()
|
||||
.translate(0, 1, 0)
|
||||
.unCentre()
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.drmangotea.createindustry.blocks.engines.radial.input.RadialEngineInp
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.drmangotea.createindustry.registry.TFMGFluids;
|
||||
import com.drmangotea.createindustry.registry.TFMGSoundEvents;
|
||||
import com.drmangotea.createindustry.registry.TFMGTags;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.content.equipment.wrench.IWrenchable;
|
||||
@@ -22,6 +23,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
@@ -35,7 +37,6 @@ import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
|
||||
@@ -490,7 +491,7 @@ public void write(CompoundTag compound, boolean clientPacket) {
|
||||
soundTimer++;
|
||||
|
||||
// if(!isExhaustTankFull()) {
|
||||
if (soundTimer >= ((16-signal)/0.8)+1) {
|
||||
if (soundTimer >= (((16-signal)/0.8)+1)/8) {
|
||||
if(signal!=0&&
|
||||
tankInventory.getFluidAmount()!=0 &&
|
||||
!overStressed
|
||||
@@ -584,7 +585,7 @@ public void write(CompoundTag compound, boolean clientPacket) {
|
||||
return new SmartFluidTank(1000, this::onFluidStackChanged){
|
||||
@Override
|
||||
public boolean isFluidValid(FluidStack stack) {
|
||||
return stack.getFluid().isSame(validFuel());
|
||||
return stack.getFluid().is(validFuel());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -633,8 +634,8 @@ public void write(CompoundTag compound, boolean clientPacket) {
|
||||
return tankInventory;
|
||||
}
|
||||
|
||||
public Fluid validFuel(){
|
||||
return TFMGFluids.GASOLINE.get();
|
||||
public TagKey<Fluid> validFuel(){
|
||||
return TFMGTags.TFMGFluidTags.GASOLINE.tag;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class RadialEngineRenderer extends KineticBlockEntityRenderer<RadialEngin
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(RadialEngineBlockEntity be, BlockState state) {
|
||||
return CachedBufferer.partialFacing(AllPartialModels.SHAFT_HALF, state);
|
||||
return CachedBufferer.partialFacing(AllPartialModels.COGWHEEL_SHAFT, state);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,9 @@ package com.drmangotea.createindustry.blocks.engines.radial.large;
|
||||
|
||||
import com.drmangotea.createindustry.blocks.engines.radial.RadialEngineBlockEntity;
|
||||
import com.drmangotea.createindustry.registry.TFMGFluids;
|
||||
import com.drmangotea.createindustry.registry.TFMGTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
@@ -41,8 +43,7 @@ public class LargeRadialEngineBlockEntity extends RadialEngineBlockEntity {
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public Fluid validFuel(){
|
||||
return TFMGFluids.KEROSENE.get();
|
||||
public TagKey<Fluid> validFuel(){
|
||||
return TFMGTags.TFMGFluidTags.KEROSENE.tag;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.drmangotea.createindustry.blocks.engines.small.turbine.TurbineEngineT
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.drmangotea.createindustry.registry.TFMGFluids;
|
||||
import com.drmangotea.createindustry.registry.TFMGSoundEvents;
|
||||
import com.drmangotea.createindustry.registry.TFMGTags;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.content.equipment.wrench.IWrenchable;
|
||||
@@ -20,6 +21,7 @@ import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.block.DirectionalBlock;
|
||||
@@ -29,10 +31,10 @@ import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
|
||||
@@ -44,7 +46,7 @@ import java.util.Optional;
|
||||
import static com.simibubi.create.content.kinetics.base.DirectionalKineticBlock.FACING;
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public abstract class AbstractEngineTileEntity extends GeneratingKineticBlockEntity implements IHaveGoggleInformation, IWrenchable {
|
||||
public abstract class AbstractEngineBlockEntity extends GeneratingKineticBlockEntity implements IHaveGoggleInformation, IWrenchable {
|
||||
|
||||
protected LazyOptional<IFluidHandler> fluidCapability;
|
||||
protected FluidTank tankInventory;
|
||||
@@ -88,7 +90,7 @@ boolean signalChanged;
|
||||
|
||||
// protected ScrollValueBehaviour generatedSpeed;
|
||||
|
||||
public AbstractEngineTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
public AbstractEngineBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
tankInventory = createInventory();
|
||||
|
||||
@@ -285,7 +287,7 @@ boolean signalChanged;
|
||||
|
||||
|
||||
////////////////////////////////////////
|
||||
LazyOptional<IFluidHandler> handler = this.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY);
|
||||
LazyOptional<IFluidHandler> handler = this.getCapability(ForgeCapabilities.FLUID_HANDLER);
|
||||
Optional<IFluidHandler> resolve = handler.resolve();
|
||||
if (!resolve.isPresent())
|
||||
return false;
|
||||
@@ -443,7 +445,7 @@ public void write(CompoundTag compound, boolean clientPacket) {
|
||||
soundTimer++;
|
||||
|
||||
// if(!isExhaustTankFull()) {
|
||||
if (soundTimer >= ((16-signal)/0.8)+1) {
|
||||
if (soundTimer >= (((16-signal)/0.8)+1)/2) {
|
||||
if(signal!=0&&
|
||||
hasBackPart()&&
|
||||
tankInventory.getFluidAmount()!=0 &&
|
||||
@@ -542,11 +544,11 @@ public void write(CompoundTag compound, boolean clientPacket) {
|
||||
private void makeSound(){
|
||||
soundTimer=0;
|
||||
if(this instanceof TurbineEngineTileEntity){
|
||||
TFMGSoundEvents.ENGINE.playAt(level, worldPosition, 0.2f, 1.5f, false);
|
||||
TFMGSoundEvents.ENGINE.playAt(level, worldPosition, 0.06f, 1.5f, false);
|
||||
}
|
||||
else
|
||||
|
||||
TFMGSoundEvents.ENGINE.playAt(level, worldPosition, 0.3f, 1f, false);
|
||||
TFMGSoundEvents.ENGINE.playAt(level, worldPosition, 0.1f, 1f, false);
|
||||
|
||||
|
||||
}
|
||||
@@ -567,7 +569,7 @@ public void write(CompoundTag compound, boolean clientPacket) {
|
||||
return new SmartFluidTank(1000, this::onFluidStackChanged){
|
||||
@Override
|
||||
public boolean isFluidValid(FluidStack stack) {
|
||||
return stack.getFluid().isSame(validFuel());
|
||||
return stack.getFluid().is(validFuel());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -614,7 +616,7 @@ public void write(CompoundTag compound, boolean clientPacket) {
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
|
||||
|
||||
if (cap == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
||||
if (cap == ForgeCapabilities.FLUID_HANDLER)
|
||||
return fluidCapability.cast();
|
||||
return super.getCapability(cap, side);
|
||||
}
|
||||
@@ -631,8 +633,8 @@ public void write(CompoundTag compound, boolean clientPacket) {
|
||||
return tankInventory;
|
||||
}
|
||||
|
||||
public Fluid validFuel(){
|
||||
return TFMGFluids.GASOLINE.get();
|
||||
public TagKey<Fluid> validFuel(){
|
||||
return TFMGTags.TFMGFluidTags.GASOLINE.tag;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -7,14 +7,14 @@ import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class UniversalEngineRenderer extends KineticBlockEntityRenderer<AbstractEngineTileEntity> {
|
||||
public class UniversalEngineRenderer extends KineticBlockEntityRenderer<AbstractEngineBlockEntity> {
|
||||
|
||||
public UniversalEngineRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(AbstractEngineTileEntity be, BlockState state) {
|
||||
protected SuperByteBuffer getRotatedModel(AbstractEngineBlockEntity be, BlockState state) {
|
||||
return CachedBufferer.partialFacing(AllPartialModels.SHAFT_HALF, state);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.drmangotea.createindustry.blocks.engines.small.gasoline;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.blocks.engines.small.AbstractEngineTileEntity;
|
||||
import com.drmangotea.createindustry.blocks.engines.small.AbstractEngineBlockEntity;
|
||||
import com.drmangotea.createindustry.registry.TFMGFluids;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
|
||||
public class GasolineEngineTileEntity extends AbstractEngineTileEntity {
|
||||
public class GasolineEngineTileEntity extends AbstractEngineBlockEntity {
|
||||
|
||||
|
||||
public GasolineEngineTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
@@ -16,8 +17,4 @@ public class GasolineEngineTileEntity extends AbstractEngineTileEntity {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fluid validFuel() {
|
||||
return TFMGFluids.GASOLINE.getSource();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package com.drmangotea.createindustry.blocks.engines.small.lpg;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.blocks.engines.small.AbstractEngineTileEntity;
|
||||
import com.drmangotea.createindustry.blocks.engines.small.AbstractEngineBlockEntity;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.drmangotea.createindustry.registry.TFMGFluids;
|
||||
import com.drmangotea.createindustry.registry.TFMGTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.level.block.DirectionalBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
|
||||
public class LPGEngineTileEntity extends AbstractEngineTileEntity {
|
||||
public class LPGEngineTileEntity extends AbstractEngineBlockEntity {
|
||||
|
||||
|
||||
public LPGEngineTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
@@ -48,7 +50,7 @@ public class LPGEngineTileEntity extends AbstractEngineTileEntity {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public Fluid validFuel() {
|
||||
return TFMGFluids.LPG.getSource();
|
||||
public TagKey<Fluid> validFuel() {
|
||||
return TFMGTags.TFMGFluidTags.LPG.tag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package com.drmangotea.createindustry.blocks.engines.small.turbine;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.blocks.engines.small.AbstractEngineTileEntity;
|
||||
import com.drmangotea.createindustry.blocks.engines.small.AbstractEngineBlockEntity;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.drmangotea.createindustry.registry.TFMGFluids;
|
||||
import com.drmangotea.createindustry.registry.TFMGTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.level.block.DirectionalBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
|
||||
public class TurbineEngineTileEntity extends AbstractEngineTileEntity {
|
||||
public class TurbineEngineTileEntity extends AbstractEngineBlockEntity {
|
||||
|
||||
|
||||
public TurbineEngineTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
@@ -49,7 +51,7 @@ public class TurbineEngineTileEntity extends AbstractEngineTileEntity {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public Fluid validFuel() {
|
||||
return TFMGFluids.KEROSENE.getSource();
|
||||
public TagKey<Fluid> validFuel() {
|
||||
return TFMGTags.TFMGFluidTags.KEROSENE.tag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
package com.drmangotea.createindustry.blocks.fluids;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraftforge.fluids.ForgeFlowingFluid;
|
||||
|
||||
/**
|
||||
* makes fluid burn when close to fire,
|
||||
* not working for now
|
||||
*/
|
||||
public class BurnableFluid extends ForgeFlowingFluid {
|
||||
|
||||
|
||||
protected BurnableFluid(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSource(FluidState p_76140_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount(FluidState p_164509_) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomTick(Level level, BlockPos pos, FluidState p_230574_, RandomSource randomSource) {
|
||||
//level.setBlock(pos,Blocks.FIRE.defaultBlockState(),3);
|
||||
// if (!level.isClientSide) {
|
||||
|
||||
// Direction checkedDirection=Direction.NORTH;
|
||||
// for(int i = 0; i < 4; i++) {
|
||||
|
||||
// checkedDirection=checkedDirection.getClockWise();
|
||||
|
||||
// BlockPos checkedPos = pos.relative(checkedDirection);
|
||||
|
||||
// if(level.getBlockEntity(checkedPos).getBlockState().is(Blocks.FIRE)) {
|
||||
// level.explode(null, pos.getX(), pos.getY(), pos.getZ(), 2.0F, Explosion.BlockInteraction.NONE);
|
||||
// level.setBlock(pos,Blocks.FIRE.defaultBlockState(),3);
|
||||
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
protected boolean isRandomlyTicking() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
public static class Flowing extends BurnableFluid {
|
||||
public Flowing(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
protected void createFluidStateDefinition(StateDefinition.Builder<Fluid, FluidState> p_76260_) {
|
||||
super.createFluidStateDefinition(p_76260_);
|
||||
p_76260_.add(LEVEL);
|
||||
}
|
||||
|
||||
public int getAmount(FluidState p_76264_) {
|
||||
return p_76264_.getValue(LEVEL);
|
||||
}
|
||||
|
||||
public boolean isSource(FluidState p_76262_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Source extends BurnableFluid {
|
||||
public Source(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public int getAmount(FluidState p_76269_) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
public boolean isSource(FluidState p_76267_) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,6 +133,7 @@ public class ExhaustBlockEntity extends SmartBlockEntity implements IHaveGoggleI
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
protected void onFluidStackChanged(FluidStack newFluidStack) {
|
||||
sendData();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.drmangotea.createindustry.blocks.machines.flarestack;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGFluids;
|
||||
import com.drmangotea.createindustry.registry.TFMGTags;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
@@ -127,19 +128,7 @@ public class FlarestackBlockEntity extends SmartBlockEntity implements IHaveGogg
|
||||
return new SmartFluidTank(1000, this::onFluidStackChanged) {
|
||||
@Override
|
||||
public boolean isFluidValid(FluidStack stack) {
|
||||
return
|
||||
stack.getFluid().isSame(TFMGFluids.BUTANE.getSource())||
|
||||
stack.getFluid().isSame(TFMGFluids.PROPANE.getSource())||
|
||||
stack.getFluid().isSame(TFMGFluids.LPG.getSource())||
|
||||
stack.getFluid().isSame(TFMGFluids.KEROSENE.getSource())||
|
||||
stack.getFluid().isSame(TFMGFluids.NAPHTHA.getSource())||
|
||||
stack.getFluid().isSame(TFMGFluids.ETHYLENE.getSource())||
|
||||
stack.getFluid().isSame(TFMGFluids.PROPYLENE.getSource())||
|
||||
stack.getFluid().isSame(TFMGFluids.DIESEL.getSource())||
|
||||
stack.getFluid().isSame(TFMGFluids.LUBRICATION_OIL.getSource())||
|
||||
stack.getFluid().isSame(TFMGFluids.HEAVY_OIL.getSource())||
|
||||
stack.getFluid().isSame(TFMGFluids.CREOSOTE.getSource())||
|
||||
stack.getFluid().isSame(TFMGFluids.GASOLINE.getSource());
|
||||
return stack.getFluid().is(TFMGTags.TFMGFluidTags.FLAMMABLE.tag);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.drmangotea.createindustry.blocks.machines.metal_processing.blast_fur
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.simibubi.create.foundation.block.IBE;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
@@ -20,7 +22,9 @@ public class BlastFurnaceOutputBlock extends HorizontalDirectionalBlock implemen
|
||||
public Class<BlastFurnaceOutputBlockEntity> getBlockEntityClass() {
|
||||
return BlastFurnaceOutputBlockEntity.class;
|
||||
}
|
||||
|
||||
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
IBE.onRemove(state, worldIn, pos, newState);
|
||||
}
|
||||
@Override
|
||||
public BlockEntityType<? extends BlastFurnaceOutputBlockEntity> getBlockEntityType() {
|
||||
return TFMGBlockEntities.BLAST_FURNACE_OUTPUT.get();
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.drmangotea.createindustry.registry.TFMGRecipeTypes;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
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.LangBuilder;
|
||||
@@ -25,11 +26,10 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||
@@ -94,6 +94,14 @@ public class BlastFurnaceOutputBlockEntity extends TFMGMachineBlockEntity implem
|
||||
tank1.getPrimaryHandler().setCapacity(8000);
|
||||
tank2.getPrimaryHandler().setCapacity(8000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
super.destroy();
|
||||
ItemHelper.dropContents(level, worldPosition, inputInventory);
|
||||
ItemHelper.dropContents(level, worldPosition, fuelInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
|
||||
super.addBehaviours(behaviours);
|
||||
@@ -105,16 +113,10 @@ public class BlastFurnaceOutputBlockEntity extends TFMGMachineBlockEntity implem
|
||||
manageMoltenMetal();
|
||||
|
||||
|
||||
|
||||
|
||||
if(type== BlastFurnaceType.SMALL) {
|
||||
blastFurnaceLevel = ((float) validHeight / 2) - 1;
|
||||
blastFurnaceLevel = (float) Math.min(blastFurnaceLevel,2.5);
|
||||
}
|
||||
if(type== BlastFurnaceType.BIG_LEFT||type== BlastFurnaceType.BIG_RIGHT){
|
||||
blastFurnaceLevel = validHeight;
|
||||
blastFurnaceLevel = Math.min(blastFurnaceLevel,15);
|
||||
}
|
||||
|
||||
|
||||
if(speedModifier!=0) {
|
||||
@@ -213,14 +215,9 @@ public class BlastFurnaceOutputBlockEntity extends TFMGMachineBlockEntity implem
|
||||
|
||||
public void manageMoltenMetal(){
|
||||
BlockPos posToSpawn;
|
||||
BlockPos posToSpawn1;
|
||||
BlockPos posToSpawn2;
|
||||
BlockPos posToSpawn3;
|
||||
BlockPos posToSpawn4;
|
||||
BlockPos posToSpawn5;
|
||||
|
||||
|
||||
if (timer>0&&type == BlastFurnaceType.SMALL) {
|
||||
if (timer>0) {
|
||||
posToSpawn = this.getBlockPos().relative(outputFacing.getOpposite()).above();
|
||||
|
||||
|
||||
@@ -236,78 +233,8 @@ public class BlastFurnaceOutputBlockEntity extends TFMGMachineBlockEntity implem
|
||||
}
|
||||
}
|
||||
|
||||
//////
|
||||
if (timer>0&&type == BlastFurnaceType.BIG_LEFT) {
|
||||
posToSpawn = this.getBlockPos().relative(outputFacing.getOpposite()).above();
|
||||
posToSpawn1 = this.getBlockPos().relative(outputFacing.getOpposite(),2).above();
|
||||
posToSpawn2 = this.getBlockPos().relative(outputFacing.getOpposite()).above().relative(outputFacing.getCounterClockWise());
|
||||
posToSpawn3 = this.getBlockPos().relative(outputFacing.getOpposite(),2).above().relative(outputFacing.getCounterClockWise());
|
||||
|
||||
|
||||
|
||||
if(!level.getBlockState(posToSpawn).is(TFMGBlocks.MOLTEN_METAL.get())) {
|
||||
level.setBlock(posToSpawn, TFMGBlocks.MOLTEN_METAL.getDefaultState(), 3);
|
||||
level.setBlock(posToSpawn1, TFMGBlocks.MOLTEN_METAL.getDefaultState(), 3);
|
||||
level.setBlock(posToSpawn2, TFMGBlocks.MOLTEN_METAL.getDefaultState(), 3);
|
||||
level.setBlock(posToSpawn3, TFMGBlocks.MOLTEN_METAL.getDefaultState(), 3);
|
||||
|
||||
level.setBlock(posToSpawn.above(), TFMGBlocks.MOLTEN_METAL.getDefaultState(), 3);
|
||||
level.setBlock(posToSpawn1.above(), TFMGBlocks.MOLTEN_METAL.getDefaultState(), 3);
|
||||
level.setBlock(posToSpawn2.above(), TFMGBlocks.MOLTEN_METAL.getDefaultState(), 3);
|
||||
level.setBlock(posToSpawn3.above(), TFMGBlocks.MOLTEN_METAL.getDefaultState(), 3);
|
||||
|
||||
}else {
|
||||
((MoltenMetalBlockEntity) level.getBlockEntity(posToSpawn)).discardTimer = 40;
|
||||
((MoltenMetalBlockEntity) level.getBlockEntity(posToSpawn.above())).discardTimer = 40;
|
||||
|
||||
((MoltenMetalBlockEntity) level.getBlockEntity(posToSpawn1)).discardTimer = 40;
|
||||
((MoltenMetalBlockEntity) level.getBlockEntity(posToSpawn1.above())).discardTimer = 40;
|
||||
|
||||
((MoltenMetalBlockEntity) level.getBlockEntity(posToSpawn2)).discardTimer = 40;
|
||||
((MoltenMetalBlockEntity) level.getBlockEntity(posToSpawn2.above())).discardTimer = 40;
|
||||
|
||||
((MoltenMetalBlockEntity) level.getBlockEntity(posToSpawn3)).discardTimer = 40;
|
||||
((MoltenMetalBlockEntity) level.getBlockEntity(posToSpawn3.above())).discardTimer = 40;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////////
|
||||
if (timer>0&&type == BlastFurnaceType.BIG_RIGHT) {
|
||||
posToSpawn = this.getBlockPos().relative(outputFacing.getOpposite()).above();
|
||||
posToSpawn1 = this.getBlockPos().relative(outputFacing.getOpposite(),2).above();
|
||||
posToSpawn2 = this.getBlockPos().relative(outputFacing.getOpposite()).above().relative(outputFacing.getClockWise());
|
||||
posToSpawn3 = this.getBlockPos().relative(outputFacing.getOpposite(),2).above().relative(outputFacing.getClockWise());
|
||||
|
||||
|
||||
|
||||
if(!level.getBlockState(posToSpawn).is(TFMGBlocks.MOLTEN_METAL.get())) {
|
||||
level.setBlock(posToSpawn, TFMGBlocks.MOLTEN_METAL.getDefaultState(),3);
|
||||
level.setBlock(posToSpawn1, TFMGBlocks.MOLTEN_METAL.getDefaultState(),3);
|
||||
level.setBlock(posToSpawn2, TFMGBlocks.MOLTEN_METAL.getDefaultState(),3);
|
||||
level.setBlock(posToSpawn3, TFMGBlocks.MOLTEN_METAL.getDefaultState(),3);
|
||||
|
||||
level.setBlock(posToSpawn.above(), TFMGBlocks.MOLTEN_METAL.getDefaultState(),3);
|
||||
level.setBlock(posToSpawn1.above(), TFMGBlocks.MOLTEN_METAL.getDefaultState(),3);
|
||||
level.setBlock(posToSpawn2.above(), TFMGBlocks.MOLTEN_METAL.getDefaultState(),3);
|
||||
level.setBlock(posToSpawn3.above(), TFMGBlocks.MOLTEN_METAL.getDefaultState(),3);
|
||||
}else {
|
||||
((MoltenMetalBlockEntity) level.getBlockEntity(posToSpawn)).discardTimer = 40;
|
||||
((MoltenMetalBlockEntity) level.getBlockEntity(posToSpawn.above())).discardTimer = 40;
|
||||
|
||||
((MoltenMetalBlockEntity) level.getBlockEntity(posToSpawn1)).discardTimer = 40;
|
||||
((MoltenMetalBlockEntity) level.getBlockEntity(posToSpawn1.above())).discardTimer = 40;
|
||||
|
||||
((MoltenMetalBlockEntity) level.getBlockEntity(posToSpawn2)).discardTimer = 40;
|
||||
((MoltenMetalBlockEntity) level.getBlockEntity(posToSpawn2.above())).discardTimer = 40;
|
||||
|
||||
((MoltenMetalBlockEntity) level.getBlockEntity(posToSpawn3)).discardTimer = 40;
|
||||
((MoltenMetalBlockEntity) level.getBlockEntity(posToSpawn3.above())).discardTimer = 40;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
protected AABB createRenderBoundingBox() {
|
||||
@@ -353,16 +280,23 @@ public class BlastFurnaceOutputBlockEntity extends TFMGMachineBlockEntity implem
|
||||
} else {
|
||||
|
||||
|
||||
int freeSpace = inputInventory.getStackInSlot(0).getMaxStackSize()-inputInventory.getStackInSlot(0).getCount();
|
||||
|
||||
if(itemStack.getCount()==1) {
|
||||
ItemStack stack2 = itemStack;
|
||||
stack2.setCount(2);
|
||||
itemEntity.setItem(stack2);
|
||||
}
|
||||
|
||||
int freeSpace2 = inputInventory.getStackInSlot(0).getMaxStackSize()-inputInventory.getStackInSlot(0).getCount();
|
||||
|
||||
int count = itemStack.getCount();
|
||||
if(!inputInventory.isEmpty())
|
||||
if(!inputInventory.getItem(0).is(itemStack.getItem()))
|
||||
continue;
|
||||
|
||||
if(count>freeSpace){
|
||||
itemStack.setCount(itemStack.getCount()-freeSpace);
|
||||
inputInventory.setItem(0 ,new ItemStack (itemStack.getItem(),inputInventory.getStackInSlot(0).getCount()+freeSpace));
|
||||
if(count>freeSpace2){
|
||||
itemStack.setCount(itemStack.getCount()-freeSpace2);
|
||||
inputInventory.setItem(0 ,new ItemStack (itemStack.getItem(),inputInventory.getStackInSlot(0).getCount()+freeSpace2));
|
||||
}else {
|
||||
inputInventory.setItem(0 ,new ItemStack (itemStack.getItem(),inputInventory.getStackInSlot(0).getCount()+itemStack.getCount()));
|
||||
itemEntity.discard();
|
||||
@@ -403,21 +337,12 @@ public class BlastFurnaceOutputBlockEntity extends TFMGMachineBlockEntity implem
|
||||
.forGoggles(tooltip, 1);
|
||||
|
||||
|
||||
Lang.translate("goggles.blast_furnace.size_stats")
|
||||
.style(ChatFormatting.DARK_GRAY)
|
||||
.forGoggles(tooltip, 1);
|
||||
|
||||
Lang.translate("goggles.blast_furnace.height", validHeight)
|
||||
.style(ChatFormatting.GOLD)
|
||||
.forGoggles(tooltip, 1);
|
||||
|
||||
if(type == BlastFurnaceType.SMALL) {
|
||||
Lang.translate("goggles.blast_furnace.diameter.one")
|
||||
.style(ChatFormatting.GOLD)
|
||||
.forGoggles(tooltip, 1);
|
||||
} else
|
||||
Lang.translate("goggles.blast_furnace.diameter.two")
|
||||
.style(ChatFormatting.GOLD)
|
||||
.forGoggles(tooltip, 1);
|
||||
|
||||
|
||||
|
||||
Lang.translate("goggles.misc.storage_info")
|
||||
@@ -438,57 +363,8 @@ public class BlastFurnaceOutputBlockEntity extends TFMGMachineBlockEntity implem
|
||||
|
||||
|
||||
|
||||
//--Fluid Info--//
|
||||
LazyOptional<IFluidHandler> handler = this.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY);
|
||||
Optional<IFluidHandler> resolve = handler.resolve();
|
||||
if (!resolve.isPresent())
|
||||
return false;
|
||||
|
||||
IFluidHandler tank = resolve.get();
|
||||
if (tank.getTanks() == 0)
|
||||
return false;
|
||||
|
||||
LangBuilder mb = Lang.translate("generic.unit.millibuckets");
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (!isEmpty)
|
||||
return true;
|
||||
|
||||
Lang.translate("gui.goggles.fluid_container.capacity")
|
||||
.add(Lang.number(tank.getTankCapacity(0))
|
||||
.add(mb)
|
||||
.style(ChatFormatting.DARK_GREEN))
|
||||
.style(ChatFormatting.DARK_GRAY)
|
||||
.forGoggles(tooltip, 1);
|
||||
containedFluidTooltip(tooltip, isPlayerSneaking,
|
||||
getCapability(ForgeCapabilities.FLUID_HANDLER));
|
||||
|
||||
|
||||
return true;
|
||||
@@ -518,11 +394,11 @@ public class BlastFurnaceOutputBlockEntity extends TFMGMachineBlockEntity implem
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
@SuppressWarnings("'net.minecraftforge.items.CapabilityItemHandler' is deprecated and marked for removal ")
|
||||
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, Direction side) {
|
||||
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
if (cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
return itemCapability.cast();
|
||||
if (cap == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
||||
if (cap == ForgeCapabilities.FLUID_HANDLER)
|
||||
return fluidCapability.cast();
|
||||
return super.getCapability(cap, side);
|
||||
}
|
||||
@@ -543,17 +419,10 @@ public class BlastFurnaceOutputBlockEntity extends TFMGMachineBlockEntity implem
|
||||
|
||||
if(canBeSmall())
|
||||
type = BlastFurnaceType.SMALL;
|
||||
if(canBeBigLeft())
|
||||
type = BlastFurnaceType.BIG_LEFT;
|
||||
if(canBeBigRight())
|
||||
type = BlastFurnaceType.BIG_RIGHT;
|
||||
|
||||
|
||||
if(
|
||||
!canBeBigLeft()&&
|
||||
!canBeBigRight()&&
|
||||
!canBeSmall()
|
||||
)type = BlastFurnaceType.INVALID;
|
||||
if(!canBeSmall())
|
||||
type = BlastFurnaceType.INVALID;
|
||||
|
||||
|
||||
|
||||
@@ -666,200 +535,15 @@ public class BlastFurnaceOutputBlockEntity extends TFMGMachineBlockEntity implem
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canBeBigRight(){
|
||||
mainFloor = this.getBlockPos().relative(outputFacing.getOpposite());
|
||||
|
||||
BlockPos checkedPos = this.getBlockPos().relative(outputFacing.getCounterClockWise());
|
||||
|
||||
for(int i = 0; i<4; i++){
|
||||
|
||||
|
||||
for(int y = 0; y<4; y++){
|
||||
|
||||
|
||||
|
||||
|
||||
if(
|
||||
!(i ==0 && y ==0)&&
|
||||
!(i ==3 && y ==3)&&
|
||||
!(i ==0 && y ==3)&&
|
||||
!(i ==3 && y ==0)
|
||||
|
||||
) {
|
||||
if( i ==1 && y ==0){
|
||||
if(isAboveValid(checkedPos)) {
|
||||
checkedPos = checkedPos.relative(outputFacing.getOpposite());
|
||||
continue;
|
||||
} else return false;
|
||||
}
|
||||
|
||||
if(!isValidBlock(checkedPos)) {
|
||||
return false;
|
||||
}
|
||||
if(i==0&&y==1){
|
||||
if(!isAboveValid(checkedPos,true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(
|
||||
i ==0 || i ==3 ||
|
||||
y == 0 || y == 3
|
||||
|
||||
){
|
||||
if(!isAboveValid(checkedPos)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
if(!isAboveClear(checkedPos)) {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
} else{
|
||||
//reinforcements
|
||||
if(i ==0 && y ==0)
|
||||
isReinforcement(checkedPos,true);
|
||||
|
||||
isReinforcement(checkedPos);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
checkedPos = checkedPos.relative(outputFacing.getOpposite());
|
||||
|
||||
}
|
||||
checkedPos= checkedPos.relative(outputFacing,4);
|
||||
checkedPos= checkedPos.relative(outputFacing.getClockWise());
|
||||
}
|
||||
// level.setBlock(checkedPos.above(5), Blocks.DIAMOND_BLOCK.defaultBlockState(), 3);
|
||||
return true;
|
||||
}
|
||||
public boolean canBeBigLeft(){
|
||||
mainFloor = this.getBlockPos().relative(outputFacing.getOpposite());
|
||||
|
||||
BlockPos checkedPos = this.getBlockPos().relative(outputFacing.getClockWise());
|
||||
|
||||
for(int i = 0; i<4; i++){
|
||||
|
||||
|
||||
for(int y = 0; y<4; y++){
|
||||
|
||||
|
||||
|
||||
|
||||
if(
|
||||
!(i ==0 && y ==0)&&
|
||||
!(i ==3 && y ==3)&&
|
||||
!(i ==0 && y ==3)&&
|
||||
!(i ==3 && y ==0)
|
||||
|
||||
) {
|
||||
if( i ==1 && y ==0){
|
||||
if(isAboveValid(checkedPos)) {
|
||||
checkedPos = checkedPos.relative(outputFacing.getOpposite());
|
||||
continue;
|
||||
} else return false;
|
||||
}
|
||||
|
||||
if(!isValidBlock(checkedPos)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(i==0&&y==1){
|
||||
if(!isAboveValid(checkedPos,true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(
|
||||
i ==0 || i ==3 ||
|
||||
y == 0 || y == 3
|
||||
|
||||
){
|
||||
if(!isAboveValid(checkedPos)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
if(!isAboveClear(checkedPos)) {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
//reinforcements
|
||||
if(i ==0 && y ==0)
|
||||
isReinforcement(checkedPos,true);
|
||||
|
||||
isReinforcement(checkedPos);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
checkedPos = checkedPos.relative(outputFacing.getOpposite());
|
||||
|
||||
}
|
||||
checkedPos= checkedPos.relative(outputFacing,4);
|
||||
checkedPos= checkedPos.relative(outputFacing.getCounterClockWise());
|
||||
}
|
||||
// level.setBlock(checkedPos.above(5), Blocks.EMERALD_BLOCK.defaultBlockState(), 3);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<ItemEntity> getItemsToPick(BlastFurnaceType type) {
|
||||
AABB searchArea=null;
|
||||
AABB searchArea1=null;
|
||||
AABB searchArea2=null;
|
||||
AABB searchArea3=null;
|
||||
|
||||
if(type == BlastFurnaceType.SMALL)
|
||||
searchArea = new AABB(this.getBlockPos().relative(outputFacing.getOpposite()).above());
|
||||
|
||||
if(type == BlastFurnaceType.BIG_RIGHT) {
|
||||
searchArea = new AABB(this.getBlockPos().relative(outputFacing.getOpposite()).above());
|
||||
|
||||
searchArea1 = new AABB(this.getBlockPos().relative(outputFacing.getOpposite(), 2).above());
|
||||
searchArea2 = new AABB(this.getBlockPos().relative(outputFacing.getOpposite(), 2).above().relative(outputFacing.getClockWise()));
|
||||
searchArea3 = new AABB(this.getBlockPos().relative(outputFacing.getOpposite()).above().relative(outputFacing.getClockWise()));
|
||||
|
||||
}
|
||||
if(type == BlastFurnaceType.BIG_LEFT) {
|
||||
searchArea = new AABB(this.getBlockPos().relative(outputFacing.getOpposite()).above());
|
||||
|
||||
searchArea1 = new AABB(this.getBlockPos().relative(outputFacing.getOpposite(), 2).above());
|
||||
searchArea2 = new AABB(this.getBlockPos().relative(outputFacing.getOpposite(), 2).above().relative(outputFacing.getCounterClockWise()));
|
||||
searchArea3 = new AABB(this.getBlockPos().relative(outputFacing.getOpposite()).above().relative(outputFacing.getCounterClockWise()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(searchArea1!=null){
|
||||
List<ItemEntity> itemList= new ArrayList<>();
|
||||
itemList.addAll(level.getEntitiesOfClass(ItemEntity.class, searchArea));
|
||||
itemList.addAll(level.getEntitiesOfClass(ItemEntity.class, searchArea1));
|
||||
itemList.addAll(level.getEntitiesOfClass(ItemEntity.class, searchArea2));
|
||||
itemList.addAll(level.getEntitiesOfClass(ItemEntity.class, searchArea3));
|
||||
return itemList;
|
||||
}
|
||||
|
||||
return level.getEntitiesOfClass(ItemEntity.class, searchArea);
|
||||
return level.getEntitiesOfClass(ItemEntity.class, new AABB(this.getBlockPos().relative(outputFacing.getOpposite()).above()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public enum BlastFurnaceType{
|
||||
SMALL,
|
||||
BIG_LEFT,
|
||||
BIG_RIGHT,
|
||||
INVALID
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,30 +85,8 @@ public class BlastFurnaceRenderer extends SafeBlockEntityRenderer<BlastFurnaceOu
|
||||
.light(light)
|
||||
.renderInto(ms, vb);
|
||||
}
|
||||
int y = -1;
|
||||
if (be.type == BlastFurnaceOutputBlockEntity.BlastFurnaceType.BIG_RIGHT||be.type == BlastFurnaceOutputBlockEntity.BlastFurnaceType.BIG_LEFT) {
|
||||
|
||||
if(be.type == BlastFurnaceOutputBlockEntity.BlastFurnaceType.BIG_LEFT)
|
||||
y = -2;
|
||||
|
||||
for(int i = 0; i < 2;i++) {
|
||||
for(int x = 0; x < 2;x++) {
|
||||
CachedBufferer.partial(TFMGPartialModels.COAL_COKE_DUST_LAYER, blockState)
|
||||
.rotateY(angle)
|
||||
.centre()
|
||||
.translateX(x+y)
|
||||
.translateZ(i)
|
||||
.translateY(height)
|
||||
.light(light)
|
||||
.renderInto(ms, vb);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -43,27 +43,20 @@ public class MoltenMetalBlock extends Block implements IBE<MoltenMetalBlockEntit
|
||||
super(p_49795_);
|
||||
}
|
||||
public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
|
||||
entity.setSecondsOnFire(10);
|
||||
if(!(entity instanceof LivingEntity)){
|
||||
// if(entity instanceof ItemEntity)
|
||||
// if(!entity.fireImmune()){
|
||||
// entity.discard();
|
||||
// if(level.isClientSide)
|
||||
// level.playSound(null, pos, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, .2f,
|
||||
// 1f + Create.RANDOM.nextFloat());
|
||||
|
||||
// }
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
if(entity instanceof LivingEntity){
|
||||
|
||||
entity.makeStuckInBlock(state, new Vec3((double)0.9F, 1.5D, (double)0.9F));
|
||||
|
||||
int random = Create.RANDOM.nextInt(24);
|
||||
int random = Create.RANDOM.nextInt(24);
|
||||
|
||||
if(random==7)
|
||||
entity.hurt(DamageSource.IN_FIRE,4);
|
||||
entity.setSecondsOnFire(10);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(random==7)
|
||||
entity.hurt(DamageSource.IN_FIRE,4);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,9 @@ public class CastingBasinBlock extends Block implements IBE<CastingBasinBlockEnt
|
||||
public VoxelShape getShape(BlockState pState, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
|
||||
return AllShapes.BASIN_BLOCK_SHAPE;
|
||||
} @Override
|
||||
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
IBE.onRemove(state, worldIn, pos, newState);
|
||||
}
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.drmangotea.createindustry.recipes.casting.CastingRecipe;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
|
||||
import com.simibubi.create.foundation.item.ItemHelper;
|
||||
import com.simibubi.create.foundation.item.SmartInventory;
|
||||
import com.simibubi.create.foundation.recipe.RecipeFinder;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
@@ -126,6 +127,12 @@ public class CastingBasinBlockEntity extends TFMGMachineBlockEntity implements I
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
super.destroy();
|
||||
ItemHelper.dropContents(level, worldPosition, moldInventory);
|
||||
ItemHelper.dropContents(level, worldPosition, outputInventory);
|
||||
}
|
||||
|
||||
public void setMold(){
|
||||
if(moldInventory.isEmpty())
|
||||
|
||||
@@ -27,6 +27,10 @@ public class CokeOvenBlock extends HorizontalDirectionalBlock implements IBE<Cok
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
IBE.onRemove(state, worldIn, pos, newState);
|
||||
}
|
||||
@Override
|
||||
public InteractionResult onWrenched(BlockState state, UseOnContext context) {
|
||||
|
||||
Level level = context.getLevel();
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.drmangotea.createindustry.registry.TFMGRecipeTypes;
|
||||
import com.simibubi.create.content.equipment.wrench.IWrenchable;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
|
||||
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;
|
||||
@@ -162,6 +163,14 @@ public class CokeOvenBlockEntity extends TFMGMachineBlockEntity implements IWren
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
super.destroy();
|
||||
ItemHelper.dropContents(level, worldPosition, inputInventory);
|
||||
}
|
||||
|
||||
|
||||
public void setBlockState(){
|
||||
|
||||
if(controller == this){
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.distillation;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillery.DistilleryControllerBlockEntity;
|
||||
import com.drmangotea.createindustry.recipes.distillation.AbstractDistillationRecipe;
|
||||
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
|
||||
import com.simibubi.create.foundation.advancement.CreateAdvancement;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.simple.DeferralBehaviour;
|
||||
import com.simibubi.create.foundation.recipe.RecipeFinder;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class FluidProcessingBlockEntity extends KineticBlockEntity {
|
||||
|
||||
public DeferralBehaviour basinChecker;
|
||||
public boolean basinRemoved;
|
||||
protected AbstractDistillationRecipe recipe;
|
||||
|
||||
public FluidProcessingBlockEntity(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) {
|
||||
super(typeIn, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
|
||||
super.addBehaviours(behaviours);
|
||||
basinChecker = new DeferralBehaviour(this, this::updateController);
|
||||
behaviours.add(basinChecker);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (basinRemoved) {
|
||||
basinRemoved = false;
|
||||
onControllerRemoved();
|
||||
sendData();
|
||||
return;
|
||||
}
|
||||
|
||||
super.tick();
|
||||
}
|
||||
|
||||
protected boolean updateController() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract boolean isRunning();
|
||||
|
||||
public void startProcessing() {}
|
||||
|
||||
public boolean continueWithPreviousRecipe() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected <C extends Container> boolean matchItemlessRecipe(Recipe<C> recipe) {
|
||||
if (recipe == null)
|
||||
return false;
|
||||
Optional<DistilleryControllerBlockEntity> controller = getController();
|
||||
|
||||
if (!controller.isPresent())
|
||||
return false;
|
||||
return AbstractDistillationRecipe.match(controller.get(), recipe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected abstract void onControllerRemoved();
|
||||
|
||||
public Optional<DistilleryControllerBlockEntity> getController() {
|
||||
if (level == null)
|
||||
return Optional.empty();
|
||||
BlockEntity basinTE = level.getBlockEntity(worldPosition.below(1));
|
||||
if (!(basinTE instanceof DistilleryControllerBlockEntity))
|
||||
return Optional.empty();
|
||||
return Optional.of((DistilleryControllerBlockEntity) basinTE);
|
||||
}
|
||||
|
||||
protected Optional<CreateAdvancement> getProcessedRecipeTrigger() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
protected abstract <C extends Container> boolean matchStaticFilters(Recipe<C> recipe);
|
||||
|
||||
protected abstract Object getRecipeCacheKey();
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillation_tower;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.blocks.tanks.SteelTankBlock;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.simibubi.create.content.equipment.wrench.IWrenchable;
|
||||
import com.simibubi.create.foundation.block.IBE;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
|
||||
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
|
||||
public class DistillationControllerBlock extends FaceAttachedHorizontalDirectionalBlock
|
||||
implements IWrenchable, IBE<DistillationControllerBlockEntity> {
|
||||
|
||||
|
||||
public DistillationControllerBlock(Properties properties) {
|
||||
super(properties);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
|
||||
super.createBlockStateDefinition(pBuilder.add(FACE, FACING));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canSurvive(BlockState pState, LevelReader pLevel, BlockPos pPos) {
|
||||
return canAttach(pLevel, pPos, getConnectedDirection(pState).getOpposite());
|
||||
}
|
||||
|
||||
public static boolean canAttach(LevelReader pReader, BlockPos pPos, Direction pDirection) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlace(BlockState pState, Level pLevel, BlockPos pPos, BlockState pOldState, boolean pIsMoving) {
|
||||
SteelTankBlock.updateTowerState(pState, pLevel, pPos.relative(getFacing(pState).getOpposite()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean pIsMoving) {
|
||||
if (state.hasBlockEntity() && (!state.is(newState.getBlock()) || !newState.hasBlockEntity()))
|
||||
world.removeBlockEntity(pos);
|
||||
SteelTankBlock.updateTowerState(state, world, pos.relative(getFacing(state).getOpposite()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Direction getFacing(BlockState sideState) {
|
||||
return getConnectedDirection(sideState);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<DistillationControllerBlockEntity> getBlockEntityClass() {
|
||||
return DistillationControllerBlockEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends DistillationControllerBlockEntity> getBlockEntityType() {
|
||||
return TFMGBlockEntities.STEEL_DISTILLATION_CONTROLLER.get();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,229 +0,0 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillation_tower;
|
||||
|
||||
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillery.DistilleryControllerBlockEntity;
|
||||
import com.drmangotea.createindustry.blocks.tanks.SteelTankBlockEntity;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.LangBuilder;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class DistillationControllerBlockEntity extends DistilleryControllerBlockEntity implements IHaveGoggleInformation {
|
||||
|
||||
public WeakReference<SteelTankBlockEntity> source;
|
||||
|
||||
public int towerLevel =0;
|
||||
public boolean hasTank = false;
|
||||
public boolean isTallEnough = true;
|
||||
public boolean hasMainOutput = false;
|
||||
public DistillationOutputBlockEntity mainOutput;
|
||||
|
||||
public DistillationControllerBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
source = new WeakReference<>(null);
|
||||
super.tick();
|
||||
|
||||
|
||||
|
||||
BlockEntity entityAbove = level.getBlockEntity(getBlockPos().above());
|
||||
|
||||
if(entityAbove instanceof DistillationOutputBlockEntity){
|
||||
mainOutput = (DistillationOutputBlockEntity) entityAbove;
|
||||
|
||||
hasMainOutput = true;
|
||||
}else {
|
||||
hasMainOutput = false;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
SteelTankBlockEntity tank = getTank();
|
||||
|
||||
if(tank==null){
|
||||
hasTank=false;
|
||||
towerLevel = 0;
|
||||
return;
|
||||
}
|
||||
hasTank = true;
|
||||
|
||||
towerLevel = tank.tower.towerLevel;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
|
||||
LangBuilder mb = Lang.translate("generic.unit.millibuckets");
|
||||
|
||||
|
||||
Lang.translate("goggles.distillation_tower.status")
|
||||
.style(ChatFormatting.GRAY)
|
||||
.space()
|
||||
.forGoggles(tooltip, 1);
|
||||
|
||||
|
||||
if(!hasTank) {
|
||||
Lang.translate("goggles.distillation_tower.tank_not_found")
|
||||
.style(ChatFormatting.DARK_RED)
|
||||
.forGoggles(tooltip);
|
||||
return true;
|
||||
|
||||
}else {
|
||||
|
||||
if(towerLevel<4) {
|
||||
Lang.translate("goggles.distillation_tower.level", this.towerLevel)
|
||||
.style(ChatFormatting.DARK_RED)
|
||||
.forGoggles(tooltip, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!hasMainOutput) {
|
||||
Lang.translate("goggles.distillation_tower.no_outputs")
|
||||
.style(ChatFormatting.DARK_RED)
|
||||
.forGoggles(tooltip, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
// if(getTank().getHeight()<((DistillationOutputBlockEntity)level.getBlockEntity(getBlockPos().above())).foundOutputs*2) {
|
||||
// Lang.translate("goggles.distillation_tower.not_tall_enough")
|
||||
// .style(ChatFormatting.DARK_RED)
|
||||
// .forGoggles(tooltip, 1);
|
||||
// return true;
|
||||
// }
|
||||
|
||||
Lang.translate("goggles.distillation_tower.level", this.towerLevel)
|
||||
.style(ChatFormatting.GREEN)
|
||||
.forGoggles(tooltip, 1);
|
||||
|
||||
Lang.translate("goggles.distillation_tower.found_outputs", this.getOutputCount())
|
||||
.style(ChatFormatting.GREEN)
|
||||
.space()
|
||||
.forGoggles(tooltip, 1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////
|
||||
LazyOptional<IFluidHandler> handler = this.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY);
|
||||
Optional<IFluidHandler> resolve = handler.resolve();
|
||||
if (!resolve.isPresent())
|
||||
return false;
|
||||
|
||||
IFluidHandler tank = resolve.get();
|
||||
if (tank.getTanks() == 0)
|
||||
return false;
|
||||
|
||||
Lang.translate("goggles.fluid_in_tank")
|
||||
.style(ChatFormatting.GRAY)
|
||||
.forGoggles(tooltip);
|
||||
|
||||
|
||||
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.GOLD))
|
||||
.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;
|
||||
}
|
||||
|
||||
if (!isEmpty)
|
||||
return true;
|
||||
|
||||
Lang.translate("gui.goggles.fluid_container.capacity")
|
||||
.add(Lang.number(tank.getTankCapacity(0))
|
||||
.add(mb)
|
||||
.style(ChatFormatting.GOLD))
|
||||
.style(ChatFormatting.DARK_GRAY)
|
||||
.forGoggles(tooltip, 1);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public int getOutputCount(){
|
||||
BlockPos checkedPos = this.getBlockPos().above(3);
|
||||
int outputCount = 1;
|
||||
|
||||
for(int i = 0; i <5;i++){
|
||||
if(
|
||||
level.getBlockState(checkedPos).is(TFMGBlocks.STEEL_DISTILLATION_OUTPUT.get())&&
|
||||
level.getBlockState(checkedPos.below()).is(TFMGBlocks.INDUSTRIAL_PIPE.get())
|
||||
){
|
||||
outputCount++;
|
||||
checkedPos = checkedPos.above(2);
|
||||
continue;
|
||||
}
|
||||
return outputCount;
|
||||
|
||||
}
|
||||
|
||||
|
||||
return outputCount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public SteelTankBlockEntity getTank() {
|
||||
SteelTankBlockEntity tank = source.get();
|
||||
if (tank == null || tank.isRemoved()) {
|
||||
if (tank != null)
|
||||
source = new WeakReference<>(null);
|
||||
Direction facing = DistillationControllerBlock.getFacing(getBlockState());
|
||||
BlockEntity be = level.getBlockEntity(worldPosition.relative(facing.getOpposite()));
|
||||
if (be instanceof SteelTankBlockEntity tankTe)
|
||||
source = new WeakReference<>(tank = tankTe);
|
||||
}
|
||||
if (tank == null)
|
||||
return null;
|
||||
return (SteelTankBlockEntity) tank.getControllerBE();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillation_tower;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.block.IBE;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
|
||||
public class DistillationOutputBlock extends Block implements IBE<DistillationOutputBlockEntity> {
|
||||
|
||||
public DistillationOutputBlock(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) {
|
||||
return !AllBlocks.BASIN.has(worldIn.getBlockState(pos.below()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<DistillationOutputBlockEntity> getBlockEntityClass() {
|
||||
return DistillationOutputBlockEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends DistillationOutputBlockEntity> getBlockEntityType() {
|
||||
return TFMGBlockEntities.STEEL_DISTILLATION_OUTPUT.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,427 +0,0 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillation_tower;
|
||||
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.CreateTFMG;
|
||||
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillery.DistilleryOutputBlockEntity;
|
||||
import com.drmangotea.createindustry.recipes.distillation.DistillationRecipe;
|
||||
import com.drmangotea.createindustry.recipes.distillation.AbstractDistillationRecipe;
|
||||
import com.drmangotea.createindustry.recipes.distillation.AdvancedDistillationRecipe;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.drmangotea.createindustry.registry.TFMGRecipeTypes;
|
||||
import com.simibubi.create.AllRecipeTypes;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.content.kinetics.press.MechanicalPressBlockEntity;
|
||||
import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
|
||||
import com.simibubi.create.foundation.recipe.RecipeFinder;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.crafting.IShapedRecipe;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class DistillationOutputBlockEntity extends DistilleryOutputBlockEntity implements IHaveGoggleInformation {
|
||||
|
||||
private static final Object AdvancedDistillationRecipesKey = new Object();
|
||||
|
||||
public int speed=3;
|
||||
public int processTimer=0;
|
||||
|
||||
public int foundOutputs=0;
|
||||
public int recipeOutputs=6;
|
||||
|
||||
public DistillationOutputBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
}
|
||||
|
||||
protected <C extends Container> boolean matchItemlessRecipe(Recipe<C> recipe) {
|
||||
if (recipe == null)
|
||||
return false;
|
||||
Optional<DistillationControllerBlockEntity> controller = getDistillationController();
|
||||
if (!controller.isPresent())
|
||||
return false;
|
||||
return AbstractDistillationRecipe.match2(controller.get(), recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean updateController() {
|
||||
|
||||
|
||||
if (level == null || level.isClientSide)
|
||||
return true;
|
||||
|
||||
DistillationControllerBlockEntity be=null;
|
||||
|
||||
if(level.getBlockEntity(getBlockPos().below())instanceof DistillationControllerBlockEntity)
|
||||
be = (DistillationControllerBlockEntity) level.getBlockEntity(getBlockPos().below());
|
||||
|
||||
if(be==null)
|
||||
return true;
|
||||
|
||||
recipe = getMatchingRecipes(be);
|
||||
|
||||
//List<Recipe<?>> recipes = getMatchingRecipes();
|
||||
//if (recipes.isEmpty())
|
||||
// return true;
|
||||
//currentRecipe = recipes.get(0);
|
||||
|
||||
|
||||
|
||||
startProcessing();
|
||||
sendData();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
|
||||
if (level != null) {
|
||||
if ((!level.isClientSide || isVirtual())) {
|
||||
process();
|
||||
sendData();
|
||||
}
|
||||
}
|
||||
if (syncCooldown > 0) {
|
||||
syncCooldown--;
|
||||
if (syncCooldown == 0 && queuedSync)
|
||||
sendData();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void process() {
|
||||
updateController();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// if((currentRecipe instanceof ShapelessRecipe))
|
||||
// return;
|
||||
|
||||
BlockEntity above1 = level.getBlockEntity(this.getBlockPos().above(2));
|
||||
BlockEntity above2 = level.getBlockEntity(this.getBlockPos().above(4));
|
||||
BlockEntity above3 = level.getBlockEntity(this.getBlockPos().above(6));
|
||||
BlockEntity above4 = level.getBlockEntity(this.getBlockPos().above(8));
|
||||
BlockEntity above5 = level.getBlockEntity(this.getBlockPos().above(10));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Optional<DistillationControllerBlockEntity> optionalController = getDistillationController();
|
||||
if (!optionalController.isPresent())
|
||||
return;
|
||||
foundOutputs = 1;
|
||||
|
||||
if(above1 instanceof DistillationOutputBlockEntity)
|
||||
foundOutputs = 2;
|
||||
|
||||
|
||||
if(above2 instanceof DistillationOutputBlockEntity) {
|
||||
if(foundOutputs==2) {
|
||||
foundOutputs = 3;
|
||||
}else foundOutputs = 1;
|
||||
}
|
||||
|
||||
|
||||
if(above3 instanceof DistillationOutputBlockEntity) {
|
||||
if(foundOutputs==3) {
|
||||
foundOutputs = 4;
|
||||
}else foundOutputs = 2;
|
||||
}
|
||||
|
||||
if(above4 instanceof DistillationOutputBlockEntity) {
|
||||
if(foundOutputs==4) {
|
||||
foundOutputs = 5;
|
||||
}else foundOutputs = 3;
|
||||
}
|
||||
if(above5 instanceof DistillationOutputBlockEntity) {
|
||||
if(foundOutputs==5) {
|
||||
foundOutputs = 6;
|
||||
}else foundOutputs = 4;
|
||||
}
|
||||
|
||||
if (recipe == null)
|
||||
return;
|
||||
|
||||
|
||||
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>foundOutputs)
|
||||
return;
|
||||
FluidStack fluidInRecipe1=null;
|
||||
FluidStack fluidInRecipe2=null;
|
||||
FluidStack fluidInRecipe3=null;
|
||||
FluidStack fluidInRecipe4=null;
|
||||
FluidStack fluidInRecipe5=null;
|
||||
FluidStack fluidInRecipe6=null;
|
||||
|
||||
fluidInRecipe1 = ((AdvancedDistillationRecipe) recipe).getFirstFluidResult();
|
||||
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=2)
|
||||
fluidInRecipe2 = ((AdvancedDistillationRecipe) recipe).getSecondFluidResult();
|
||||
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=3)
|
||||
fluidInRecipe3 = ((AdvancedDistillationRecipe) recipe).getThirdFluidResult();
|
||||
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=4)
|
||||
fluidInRecipe4 = ((AdvancedDistillationRecipe) recipe).getFourthFluidResult();
|
||||
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=5)
|
||||
fluidInRecipe5 = ((AdvancedDistillationRecipe) recipe).getFifthFluidResult();
|
||||
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=6)
|
||||
fluidInRecipe6 = ((AdvancedDistillationRecipe) recipe).getSixthFluidResult();
|
||||
|
||||
|
||||
|
||||
if(!hasIndustrialPipes(foundOutputs))
|
||||
return;
|
||||
|
||||
//
|
||||
if (fluidInRecipe1.getFluid() != this.tankInventory.getFluid().getFluid()
|
||||
&& tankInventory.getFluidAmount()!=0
|
||||
)
|
||||
return;
|
||||
if(fluidInRecipe2!=null)
|
||||
if(above1 instanceof DistillationOutputBlockEntity)
|
||||
if(foundOutputs>=2)
|
||||
if (fluidInRecipe2.getFluid() != (((DistillationOutputBlockEntity) above1).tankInventory.getFluid().getFluid())
|
||||
&&((DistillationOutputBlockEntity) above1).tankInventory.getFluidAmount()!=0
|
||||
)
|
||||
return;
|
||||
if(fluidInRecipe3!=null)
|
||||
if(above2 instanceof DistillationOutputBlockEntity)
|
||||
if(foundOutputs>=3)
|
||||
if (fluidInRecipe3.getFluid() != (((DistillationOutputBlockEntity) above2).tankInventory.getFluid().getFluid())
|
||||
&&((DistillationOutputBlockEntity) above2).tankInventory.getFluidAmount()!=0
|
||||
)
|
||||
return;
|
||||
if(fluidInRecipe4!=null)
|
||||
if(above3 instanceof DistillationOutputBlockEntity)
|
||||
if(foundOutputs>=4)
|
||||
if (fluidInRecipe4.getFluid() != (((DistillationOutputBlockEntity) above3).tankInventory.getFluid().getFluid())
|
||||
&&((DistillationOutputBlockEntity) above3).tankInventory.getFluidAmount()!=0
|
||||
)
|
||||
return;
|
||||
if(fluidInRecipe5!=null)
|
||||
if(above4 instanceof DistillationOutputBlockEntity)
|
||||
if(foundOutputs>=5)
|
||||
if (fluidInRecipe5.getFluid() != (((DistillationOutputBlockEntity) above4).tankInventory.getFluid().getFluid())
|
||||
&&((DistillationOutputBlockEntity) above4).tankInventory.getFluidAmount()!=0
|
||||
)
|
||||
return;
|
||||
if(fluidInRecipe6!=null)
|
||||
if(above5 instanceof DistillationOutputBlockEntity)
|
||||
if(foundOutputs>=6)
|
||||
if (fluidInRecipe6.getFluid() != (((DistillationOutputBlockEntity) above5).tankInventory.getFluid().getFluid())
|
||||
&&((DistillationOutputBlockEntity) above5).tankInventory.getFluidAmount()!=0
|
||||
)
|
||||
return;
|
||||
//
|
||||
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=1)
|
||||
if(tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) recipe).getFirstFluidResult().getAmount()>8000)
|
||||
return;
|
||||
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=2)
|
||||
if(((DistillationOutputBlockEntity)above1).tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) recipe).getSecondFluidResult().getAmount()>8000)
|
||||
return;
|
||||
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=3)
|
||||
if(((DistillationOutputBlockEntity)above2).tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) recipe).getThirdFluidResult().getAmount()>8000)
|
||||
return;
|
||||
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=4)
|
||||
if(((DistillationOutputBlockEntity)above3).tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) recipe).getFourthFluidResult().getAmount()>8000)
|
||||
return;
|
||||
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=5)
|
||||
if(((DistillationOutputBlockEntity)above4).tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) recipe).getFifthFluidResult().getAmount()>8000)
|
||||
return;
|
||||
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=6)
|
||||
if(((DistillationOutputBlockEntity)above5).tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) recipe).getSixthFluidResult().getAmount()>8000)
|
||||
return;
|
||||
|
||||
if(getDistillationController().get().getTanks().get(true).getPrimaryHandler().getFluid().getFluid() != ((AdvancedDistillationRecipe) recipe).getInputFluid().getMatchingFluidStacks().get(0).getFluid())
|
||||
return;
|
||||
|
||||
DistillationControllerBlockEntity controller = optionalController.get();
|
||||
|
||||
|
||||
|
||||
if (!controller.getTanks().get(true).isEmpty()) {
|
||||
|
||||
|
||||
// if(((AdvancedDistillationRecipe)currentRecipe).getInputFluid().getMatchingFluidStacks().get(0).getFluid() != TFMGFluids.HEAVY_OIL.get())
|
||||
// return;
|
||||
|
||||
|
||||
if(!controller.hasTank)
|
||||
return;
|
||||
|
||||
|
||||
if(controller.towerLevel<4)
|
||||
return;
|
||||
|
||||
if(controller.towerLevel>=12) {
|
||||
speed = 3;
|
||||
} else speed=6;
|
||||
|
||||
if(processTimer<speed){
|
||||
processTimer++;
|
||||
return;
|
||||
}
|
||||
processTimer=0;
|
||||
|
||||
|
||||
int desiredHeight = (foundOutputs*2)+1;
|
||||
if(controller.getTank().height<desiredHeight)
|
||||
return;
|
||||
|
||||
if(!level.isClientSide) {
|
||||
controller.getTanks().get(true).getPrimaryHandler().drain(((AdvancedDistillationRecipe) recipe).getFluidIngredients().get(0).getRequiredAmount(), IFluidHandler.FluidAction.EXECUTE);
|
||||
|
||||
|
||||
tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) recipe).getFirstFluidResult().getFluid(), ((AdvancedDistillationRecipe) recipe).getFirstFluidResult().getAmount() + this.tankInventory.getFluidAmount()));
|
||||
if(above1 instanceof DistillationOutputBlockEntity)
|
||||
if(foundOutputs>=2)
|
||||
if (((AdvancedDistillationRecipe) recipe).getResults().toArray().length>1)
|
||||
((DistillationOutputBlockEntity) above1).tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) recipe).getSecondFluidResult().getFluid(), ((AdvancedDistillationRecipe) recipe).getSecondFluidResult().getAmount() + ((DistillationOutputBlockEntity) above1).tankInventory.getFluidAmount()));
|
||||
if(above2 instanceof DistillationOutputBlockEntity)
|
||||
if(foundOutputs>=3)
|
||||
if (((AdvancedDistillationRecipe) recipe).getResults().toArray().length>2)
|
||||
((DistillationOutputBlockEntity) above2).tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) recipe).getThirdFluidResult().getFluid(), ((AdvancedDistillationRecipe) recipe).getThirdFluidResult().getAmount() + ((DistillationOutputBlockEntity) above2).tankInventory.getFluidAmount()));
|
||||
if(above3 instanceof DistillationOutputBlockEntity)
|
||||
if(foundOutputs>=4)
|
||||
if (((AdvancedDistillationRecipe) recipe).getResults().toArray().length>3)
|
||||
((DistillationOutputBlockEntity) above3).tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) recipe).getFourthFluidResult().getFluid(), ((AdvancedDistillationRecipe) recipe).getFourthFluidResult().getAmount() + ((DistillationOutputBlockEntity) above3).tankInventory.getFluidAmount()));
|
||||
if(above4 instanceof DistillationOutputBlockEntity)
|
||||
if(foundOutputs>=5)
|
||||
if (((AdvancedDistillationRecipe) recipe).getResults().toArray().length>4)
|
||||
((DistillationOutputBlockEntity) above4).tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) recipe).getFifthFluidResult().getFluid(), ((AdvancedDistillationRecipe) recipe).getFifthFluidResult().getAmount() + ((DistillationOutputBlockEntity) above4).tankInventory.getFluidAmount()));
|
||||
if(above5 instanceof DistillationOutputBlockEntity)
|
||||
if(foundOutputs>=6)
|
||||
if (((AdvancedDistillationRecipe) recipe).getResults().toArray().length>5)
|
||||
((DistillationOutputBlockEntity) above5).tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) recipe).getSixthFluidResult().getFluid(), ((AdvancedDistillationRecipe) recipe).getSixthFluidResult().getAmount() + ((DistillationOutputBlockEntity) above5).tankInventory.getFluidAmount()));
|
||||
|
||||
}
|
||||
/*
|
||||
if(!(((AdvancedDistillationRecipe) currentRecipe).getThirdItemResult().isEmpty()))
|
||||
controller.outputInventory.setItem(2,((AdvancedDistillationRecipe) currentRecipe).getFirstItemResult());
|
||||
|
||||
|
||||
*/
|
||||
|
||||
controller.notifyChangeOfContents();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected List<Recipe<?>> getMatchingRecipes() {
|
||||
//
|
||||
//
|
||||
// List<Recipe<?>> list = RecipeFinder.get(getRecipeCacheKey(), level, this::matchStaticFilters);
|
||||
// return list.stream()
|
||||
// .filter(this::matchItemlessRecipe)
|
||||
// .sorted((r1, r2) -> r2.getIngredients()
|
||||
// .size()
|
||||
// - r1.getIngredients()
|
||||
// .size())
|
||||
// .collect(Collectors.toList());
|
||||
// }
|
||||
|
||||
protected AdvancedDistillationRecipe getMatchingRecipes(DistillationControllerBlockEntity be) {
|
||||
|
||||
|
||||
List<Recipe<?>> list = RecipeFinder.get(getRecipeCacheKey(), level, this::matchStaticFilters);
|
||||
|
||||
|
||||
for(int i = 0; i < list.toArray().length;i++){
|
||||
AdvancedDistillationRecipe recipe = (AdvancedDistillationRecipe) list.get(i);
|
||||
|
||||
if(recipe.getOutputCount(recipe)!=foundOutputs)
|
||||
continue;
|
||||
|
||||
for(int y = 0; y < recipe.getFluidIngredients().get(0).getMatchingFluidStacks().toArray().length;y++)
|
||||
if(be.inputTank.getPrimaryHandler().getFluid().getFluid()==recipe.getFluidIngredients().get(0).getMatchingFluidStacks().get(y).getFluid())
|
||||
if(be.inputTank.getPrimaryHandler().getFluidAmount()>=recipe.getFluidIngredients().get(0).getRequiredAmount())
|
||||
return recipe;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected <C extends Container> boolean matchStaticFilters(Recipe<C> r) {
|
||||
return r instanceof AdvancedDistillationRecipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startProcessing() {
|
||||
if (running )
|
||||
return;
|
||||
super.startProcessing();
|
||||
running = true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean continueWithPreviousRecipe() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onControllerRemoved() {
|
||||
if (!running)
|
||||
return;
|
||||
|
||||
running = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getRecipeCacheKey() {
|
||||
return AdvancedDistillationRecipesKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isRunning() {
|
||||
return running;
|
||||
}
|
||||
/*
|
||||
@Override
|
||||
protected Optional<CreateAdvancement> getProcessedRecipeTrigger() {
|
||||
return Optional.of(AllAdvancements.MIXER);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public Optional<DistillationControllerBlockEntity> getDistillationController() {
|
||||
if (level == null)
|
||||
return Optional.empty();
|
||||
BlockEntity basinTE = level.getBlockEntity(worldPosition.below(1));
|
||||
if (!(basinTE instanceof DistillationControllerBlockEntity))
|
||||
return Optional.empty();
|
||||
return Optional.of((DistillationControllerBlockEntity) basinTE);
|
||||
}
|
||||
|
||||
public boolean hasIndustrialPipes(int outputAmount){
|
||||
BlockPos checkedPos = this.getBlockPos().above();
|
||||
Block checkedBlock;
|
||||
|
||||
|
||||
for(int i = 0;i<(outputAmount-1);i++){
|
||||
checkedBlock = level.getBlockState(checkedPos).getBlock();
|
||||
if(checkedBlock == TFMGBlocks.INDUSTRIAL_PIPE.get()){
|
||||
checkedPos=checkedPos.above(2);
|
||||
continue;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,403 +0,0 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillation_tower;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.CreateTFMG;
|
||||
import com.drmangotea.createindustry.blocks.tanks.SteelTankBlock;
|
||||
import com.drmangotea.createindustry.blocks.tanks.SteelTankBlockEntity;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.drmangotea.createindustry.registry.TFMGFluids;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.content.fluids.tank.BoilerHeaters;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
|
||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
|
||||
import joptsimple.internal.Strings;
|
||||
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.network.chat.MutableComponent;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.simibubi.create.foundation.fluid.FluidHelper.convertToStill;
|
||||
|
||||
public class DistillationTowerData {
|
||||
|
||||
static final int SAMPLE_RATE = 1;
|
||||
|
||||
private static final int waterSupplyPerLevel = 10;
|
||||
private static final float passiveEngineEfficiency = 0;
|
||||
|
||||
private SteelTankBlockEntity tank;
|
||||
|
||||
// pooled water supply
|
||||
int gatheredSupply;
|
||||
float[] supplyOverTime = new float[10];
|
||||
int ticksUntilNextSample;
|
||||
int currentIndex;
|
||||
|
||||
// heat score
|
||||
public boolean needsHeatLevelUpdate;
|
||||
public boolean passiveHeat;
|
||||
public int activeHeat;
|
||||
|
||||
public float oilSupply;
|
||||
public int attachedControllers;
|
||||
public int attachedWhistles;
|
||||
|
||||
// display
|
||||
public int maxHeatForSize = 0;
|
||||
private int maxHeatForOil = 0;
|
||||
private int minValue = 0;
|
||||
private int maxValue = 0;
|
||||
|
||||
public int towerLevel = Math.min(activeHeat, maxHeatForSize);
|
||||
|
||||
public LerpedFloat gauge = LerpedFloat.linear();
|
||||
|
||||
public void tick(SteelTankBlockEntity controller) {
|
||||
|
||||
|
||||
towerLevel = activeHeat;
|
||||
tank=controller;
|
||||
// tank.tankInventory.drain(2, IFluidHandler.FluidAction.EXECUTE);
|
||||
|
||||
if (controller.getLevel().isClientSide) {
|
||||
gauge.tickChaser();
|
||||
float current = gauge.getValue(1);
|
||||
if (current > 1 && Create.RANDOM.nextFloat() < 1 / 2f)
|
||||
gauge.setValueNoUpdate(current + Math.min(-(current - 1) * Create.RANDOM.nextFloat(), 0));
|
||||
// return;
|
||||
}
|
||||
|
||||
if (needsHeatLevelUpdate && updateTemperature(controller))
|
||||
controller.notifyUpdate();
|
||||
ticksUntilNextSample--;
|
||||
if (ticksUntilNextSample > 0)
|
||||
return;
|
||||
int capacity = controller.tankInventory.getCapacity();
|
||||
if (capacity == 0)
|
||||
return;
|
||||
|
||||
|
||||
ticksUntilNextSample = SAMPLE_RATE;
|
||||
supplyOverTime[currentIndex] = gatheredSupply / (float) SAMPLE_RATE;
|
||||
oilSupply = Math.max(oilSupply, supplyOverTime[currentIndex]);
|
||||
currentIndex = (currentIndex + 1) % supplyOverTime.length;
|
||||
gatheredSupply = 0;
|
||||
|
||||
|
||||
if (currentIndex == 0) {
|
||||
oilSupply = 0;
|
||||
for (float i : supplyOverTime)
|
||||
oilSupply = Math.max(i, oilSupply);
|
||||
}
|
||||
|
||||
/*
|
||||
if (getActualHeat(controller.getTotalTankSize()) == 18)
|
||||
controller.award(AllAdvancements.STEAM_ENGINE_MAXED);
|
||||
*/
|
||||
controller.notifyUpdate();
|
||||
|
||||
}
|
||||
|
||||
public int getTheoreticalHeatLevel() {
|
||||
return activeHeat;
|
||||
}
|
||||
|
||||
public int getMaxHeatLevelForBoilerSize(int towerSize) {
|
||||
return (int) Math.min(12, towerSize / 4);
|
||||
}
|
||||
|
||||
public int getMaxHeatLevelForOilSupply() {
|
||||
return (int) Math.min(12, Mth.ceil(oilSupply) / waterSupplyPerLevel);
|
||||
}
|
||||
|
||||
public boolean isPassive() {
|
||||
return passiveHeat && maxHeatForSize > 0 && maxHeatForOil > 0;
|
||||
}
|
||||
|
||||
public boolean isPassive(int towerSize) {
|
||||
calcMinMaxForSize(towerSize);
|
||||
return isPassive();
|
||||
}
|
||||
|
||||
public float getTowerEfficiency(int towerSize) {
|
||||
if (isPassive(towerSize))
|
||||
return 0;
|
||||
if (activeHeat == 0)
|
||||
return 0;
|
||||
int actualHeat = getActualHeat(towerSize);
|
||||
return this.towerLevel;
|
||||
}
|
||||
|
||||
public int getActualHeat(int towerSize) {
|
||||
int forBoilerSize = getMaxHeatLevelForBoilerSize(towerSize);
|
||||
int forWaterSupply = getMaxHeatLevelForOilSupply();
|
||||
int actualHeat = Math.min(activeHeat, Math.min(forWaterSupply, forBoilerSize));
|
||||
return actualHeat;
|
||||
}
|
||||
|
||||
public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking, int towerSize) {
|
||||
if (!isActive())
|
||||
return false;
|
||||
|
||||
Component indent = Components.literal(IHaveGoggleInformation.spacing);
|
||||
Component indent2 = Components.literal(IHaveGoggleInformation.spacing + " ");
|
||||
|
||||
calcMinMaxForSize(towerSize);
|
||||
|
||||
tooltip.add(indent.plainCopy()
|
||||
.append(
|
||||
Lang.translateDirect("distillation_tower.status", getHeatLevelTextComponent().withStyle(ChatFormatting.AQUA))));
|
||||
tooltip.add(indent2.plainCopy()
|
||||
.append(getSizeComponent(true, false)));
|
||||
// tooltip.add(indent2.plainCopy()
|
||||
//.append(getOilComponent(true, false)));
|
||||
tooltip.add(indent2.plainCopy()
|
||||
.append(getHeatComponent(true, false)));
|
||||
|
||||
if (attachedControllers == 0)
|
||||
return true;
|
||||
|
||||
int boilerLevel = Math.min(activeHeat, maxHeatForSize);
|
||||
|
||||
|
||||
tooltip.add(Components.immutableEmpty());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void calcMinMaxForSize(int towerSize) {
|
||||
maxHeatForSize = getMaxHeatLevelForBoilerSize(towerSize);
|
||||
maxHeatForOil = getMaxHeatLevelForOilSupply();
|
||||
|
||||
minValue = Math.min(passiveHeat ? 1 : activeHeat, Math.min(maxHeatForOil, maxHeatForSize));
|
||||
maxValue = Math.max(passiveHeat ? 1 : activeHeat, Math.max(maxHeatForOil, maxHeatForSize));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public MutableComponent getHeatLevelTextComponent() {
|
||||
int boilerLevel = Math.min(activeHeat, Math.min(maxHeatForOil, maxHeatForSize));
|
||||
|
||||
return isPassive() ? Lang.translateDirect("boiler.passive")
|
||||
: (boilerLevel == 0 ? Lang.translateDirect("boiler.idle")
|
||||
: boilerLevel == 18 ? Lang.translateDirect("boiler.max_lvl")
|
||||
: Lang.translateDirect("boiler.lvl", String.valueOf(boilerLevel)));
|
||||
}
|
||||
|
||||
public MutableComponent getSizeComponent(boolean forGoggles, boolean useBlocksAsBars, ChatFormatting... styles) {
|
||||
return componentHelper("size", maxHeatForSize, forGoggles, useBlocksAsBars, styles);
|
||||
}
|
||||
/*
|
||||
public MutableComponent getOilComponent(boolean forGoggles, boolean useBlocksAsBars, ChatFormatting... styles) {
|
||||
return componentHelper("crude_oil", maxHeatForOil, forGoggles, useBlocksAsBars, styles);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
public MutableComponent getHeatComponent(boolean forGoggles, boolean useBlocksAsBars, ChatFormatting... styles) {
|
||||
return componentHelper("heat", passiveHeat ? 1 : activeHeat, forGoggles, useBlocksAsBars, styles);
|
||||
}
|
||||
|
||||
private MutableComponent componentHelper(String label, int level, boolean forGoggles, boolean useBlocksAsBars,
|
||||
ChatFormatting... styles) {
|
||||
MutableComponent base = useBlocksAsBars ? blockComponent(level) : barComponent(level);
|
||||
|
||||
if (!forGoggles)
|
||||
return base;
|
||||
|
||||
ChatFormatting style1 = styles.length >= 1 ? styles[0] : ChatFormatting.GRAY;
|
||||
ChatFormatting style2 = styles.length >= 2 ? styles[1] : ChatFormatting.DARK_GRAY;
|
||||
|
||||
return Lang.translateDirect("distillation_tower." + label)
|
||||
.withStyle(style1)
|
||||
.append(Lang.translateDirect("boiler." + label + "_dots")
|
||||
.withStyle(style2))
|
||||
.append(base);
|
||||
}
|
||||
|
||||
private MutableComponent blockComponent(int level) {
|
||||
return Components.literal(
|
||||
"" + "\u2588".repeat(minValue) + "\u2592".repeat(level - minValue) + "\u2591".repeat(maxValue - level));
|
||||
}
|
||||
|
||||
private MutableComponent barComponent(int level) {
|
||||
return Components.empty()
|
||||
.append(bars(Math.max(0, minValue - 1), ChatFormatting.DARK_GREEN))
|
||||
.append(bars(minValue > 0 ? 1 : 0, ChatFormatting.GREEN))
|
||||
.append(bars(Math.max(0, level - minValue), ChatFormatting.DARK_GREEN))
|
||||
.append(bars(Math.max(0, maxValue - level), ChatFormatting.DARK_RED))
|
||||
.append(bars(Math.max(0, Math.min(18 - maxValue, ((maxValue / 5 + 1) * 5) - maxValue)),
|
||||
ChatFormatting.DARK_GRAY));
|
||||
|
||||
}
|
||||
|
||||
private MutableComponent bars(int level, ChatFormatting format) {
|
||||
return Components.literal(Strings.repeat('|', level)).withStyle(format);
|
||||
}
|
||||
|
||||
public boolean evaluate(SteelTankBlockEntity controller) {
|
||||
BlockPos controllerPos = controller.getBlockPos();
|
||||
Level level = controller.getLevel();
|
||||
int prevEngines = attachedControllers;
|
||||
int prevWhistles = attachedWhistles;
|
||||
attachedControllers = 0;
|
||||
attachedWhistles = 0;
|
||||
|
||||
for (int yOffset = 0; yOffset < controller.height; yOffset++) {
|
||||
for (int xOffset = 0; xOffset < controller.width; xOffset++) {
|
||||
for (int zOffset = 0; zOffset < controller.width; zOffset++) {
|
||||
|
||||
BlockPos pos = controllerPos.offset(xOffset, yOffset, zOffset);
|
||||
BlockState blockState = level.getBlockState(pos);
|
||||
if (!SteelTankBlock.isTank(blockState))
|
||||
continue;
|
||||
for (Direction d : Iterate.directions) {
|
||||
BlockPos attachedPos = pos.relative(d);
|
||||
BlockState attachedState = level.getBlockState(attachedPos);
|
||||
if (TFMGBlocks.STEEL_DISTILLATION_CONTROLLER.has(attachedState) && DistillationControllerBlock.getFacing(attachedState) == d)
|
||||
attachedControllers++;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
needsHeatLevelUpdate = true;
|
||||
return prevEngines != attachedControllers || prevWhistles != attachedWhistles;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean updateTemperature(SteelTankBlockEntity controller) {
|
||||
BlockPos controllerPos = controller.getBlockPos();
|
||||
Level level = controller.getLevel();
|
||||
needsHeatLevelUpdate = false;
|
||||
|
||||
boolean prevPassive = passiveHeat;
|
||||
int prevActive = activeHeat;
|
||||
passiveHeat = false;
|
||||
activeHeat = 0;
|
||||
|
||||
for (int xOffset = 0; xOffset < controller.width; xOffset++) {
|
||||
for (int zOffset = 0; zOffset < controller.width; zOffset++) {
|
||||
BlockPos pos = controllerPos.offset(xOffset, -1, zOffset);
|
||||
BlockState blockState = level.getBlockState(pos);
|
||||
float heat = BoilerHeaters.getActiveHeat(level, pos, blockState);
|
||||
if (heat == 0) {
|
||||
passiveHeat = true;
|
||||
} else if (heat > 0) {
|
||||
activeHeat += heat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
passiveHeat &= activeHeat == 0;
|
||||
|
||||
return prevActive != activeHeat || prevPassive != passiveHeat;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return attachedControllers == 1;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
oilSupply = 0;
|
||||
activeHeat = 0;
|
||||
passiveHeat = false;
|
||||
attachedControllers = 0;
|
||||
Arrays.fill(supplyOverTime, 0);
|
||||
}
|
||||
|
||||
public CompoundTag write() {
|
||||
CompoundTag nbt = new CompoundTag();
|
||||
nbt.putFloat("Supply", oilSupply);
|
||||
nbt.putInt("ActiveHeat", activeHeat);
|
||||
nbt.putBoolean("PassiveHeat", passiveHeat);
|
||||
nbt.putInt("Engines", attachedControllers);
|
||||
nbt.putInt("Whistles", attachedWhistles);
|
||||
nbt.putBoolean("Update", needsHeatLevelUpdate);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public void read(CompoundTag nbt, int towerSize) {
|
||||
oilSupply = nbt.getFloat("Supply");
|
||||
activeHeat = nbt.getInt("ActiveHeat");
|
||||
passiveHeat = nbt.getBoolean("PassiveHeat");
|
||||
attachedControllers = nbt.getInt("Engines");
|
||||
attachedWhistles = nbt.getInt("Whistles");
|
||||
needsHeatLevelUpdate = nbt.getBoolean("Update");
|
||||
Arrays.fill(supplyOverTime, (int) oilSupply);
|
||||
|
||||
int forBoilerSize = getMaxHeatLevelForBoilerSize(towerSize);
|
||||
int forOilSupply = getMaxHeatLevelForOilSupply();
|
||||
int actualHeat = Math.min(activeHeat, Math.min(forOilSupply, forBoilerSize));
|
||||
float target = isPassive(towerSize) ? 1 / 8f : forBoilerSize == 0 ? 0 : actualHeat / (forBoilerSize * 1f);
|
||||
gauge.chase(target, 0.125f, Chaser.EXP);
|
||||
}
|
||||
|
||||
public DistillationFluidHandler createHandler() {
|
||||
return new DistillationFluidHandler();
|
||||
}
|
||||
|
||||
public class DistillationFluidHandler implements IFluidHandler {
|
||||
|
||||
@Override
|
||||
public int getTanks() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluidInTank(int tank) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTankCapacity(int tank) {
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, FluidStack stack) {
|
||||
return false;
|
||||
}
|
||||
public static boolean isOil(Fluid fluid) {
|
||||
return convertToStill(fluid) == TFMGFluids.CRUDE_OIL.get();
|
||||
}
|
||||
@Override
|
||||
public int fill(FluidStack resource, FluidAction action) {
|
||||
if (!isFluidValid(0, resource))
|
||||
return 0;
|
||||
int amount = resource.getAmount();
|
||||
if (action.execute())
|
||||
gatheredSupply += amount;
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillation_tower;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGShapes;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class IndustrialPipeBlock extends Block {
|
||||
|
||||
|
||||
public IndustrialPipeBlock(Properties p_49795_) {
|
||||
super(p_49795_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState pState, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
|
||||
return TFMGShapes.INDUSTRIAL_PIPE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillery;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.simibubi.create.content.equipment.wrench.IWrenchable;
|
||||
import com.simibubi.create.foundation.block.IBE;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
|
||||
public class DistilleryControllerBlock extends Block implements IBE<DistilleryControllerBlockEntity>, IWrenchable {
|
||||
|
||||
|
||||
public DistilleryControllerBlock(Properties p_i48440_1_) {
|
||||
super(p_i48440_1_);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
IBE.onRemove(state, worldIn, pos, newState);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<DistilleryControllerBlockEntity> getBlockEntityClass() {
|
||||
return DistilleryControllerBlockEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends DistilleryControllerBlockEntity> getBlockEntityType() {
|
||||
return TFMGBlockEntities.CAST_IRON_DISTILLATION_CONTROLLER.get();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillery;
|
||||
|
||||
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.FluidProcessingBlockEntity;
|
||||
import com.simibubi.create.AllTags;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.content.kinetics.belt.behaviour.DirectBeltInputBehaviour;
|
||||
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock;
|
||||
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.fluid.SmartFluidTankBehaviour;
|
||||
import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
|
||||
import com.simibubi.create.foundation.item.SmartInventory;
|
||||
import com.simibubi.create.foundation.utility.*;
|
||||
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.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.*;
|
||||
|
||||
public class DistilleryControllerBlockEntity extends SmartBlockEntity implements IHaveGoggleInformation {
|
||||
|
||||
public SmartFluidTankBehaviour inputTank;
|
||||
public SmartInventory outputInventory;
|
||||
public SmartFluidTankBehaviour outputTank;
|
||||
|
||||
public boolean contentsChanged;
|
||||
|
||||
public Couple<SmartFluidTankBehaviour> tanks;
|
||||
|
||||
public LazyOptional<IItemHandlerModifiable> itemCapability;
|
||||
protected LazyOptional<IFluidHandler> fluidCapability;
|
||||
|
||||
public int recipeBackupCheck;
|
||||
|
||||
public DistilleryControllerBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
|
||||
outputInventory = new SmartInventory(9, this).forbidInsertion()
|
||||
.withMaxStackSize(64);
|
||||
|
||||
itemCapability = LazyOptional.of(() -> new CombinedInvWrapper( outputInventory));
|
||||
contentsChanged = true;
|
||||
|
||||
|
||||
tanks = Couple.create(inputTank, outputTank);
|
||||
|
||||
recipeBackupCheck = 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
|
||||
behaviours.add(new DirectBeltInputBehaviour(this));
|
||||
|
||||
inputTank = new SmartFluidTankBehaviour(SmartFluidTankBehaviour.INPUT, this, 2, 1000, true)
|
||||
.whenFluidUpdates(() -> contentsChanged = true);
|
||||
outputTank = new SmartFluidTankBehaviour(SmartFluidTankBehaviour.OUTPUT, this, 2, 1000, true)
|
||||
.whenFluidUpdates(() -> contentsChanged = true)
|
||||
.forbidInsertion();
|
||||
behaviours.add(inputTank);
|
||||
behaviours.add(outputTank);
|
||||
|
||||
fluidCapability = LazyOptional.of(() -> {
|
||||
LazyOptional<? extends IFluidHandler> inputCap = inputTank.getCapability();
|
||||
LazyOptional<? extends IFluidHandler> outputCap = outputTank.getCapability();
|
||||
return new CombinedTankWrapper(outputCap.orElse(null), inputCap.orElse(null));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void read(CompoundTag compound, boolean clientPacket) {
|
||||
super.read(compound, clientPacket);
|
||||
|
||||
outputInventory.deserializeNBT(compound.getCompound("OutputItems"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(CompoundTag compound, boolean clientPacket) {
|
||||
super.write(compound, clientPacket);
|
||||
|
||||
compound.put("OutputItems", outputInventory.serializeNBT());
|
||||
|
||||
}
|
||||
/*
|
||||
@Override
|
||||
public void destroy() {
|
||||
super.destroy();
|
||||
|
||||
ItemHelper.dropContents(level, worldPosition, outputInventory);
|
||||
spoutputBuffer.forEach(is -> Block.popResource(level, worldPosition, is));
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
super.remove();
|
||||
onEmptied();
|
||||
}
|
||||
|
||||
public void onEmptied() {
|
||||
getOperator().ifPresent(te -> te.basinRemoved = true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
itemCapability.invalidate();
|
||||
fluidCapability.invalidate();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, Direction side) {
|
||||
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
return itemCapability.cast();
|
||||
if (cap == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
||||
return fluidCapability.cast();
|
||||
return super.getCapability(cap, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyUpdate() {
|
||||
super.notifyUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lazyTick() {
|
||||
super.lazyTick();
|
||||
notifyUpdate();
|
||||
if (!level.isClientSide) {
|
||||
if (recipeBackupCheck-- > 0)
|
||||
return;
|
||||
recipeBackupCheck = 20;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
|
||||
if (!contentsChanged)
|
||||
return;
|
||||
|
||||
contentsChanged = false;
|
||||
getOperator().ifPresent(te -> te.basinChecker.scheduleUpdate());
|
||||
|
||||
for (Direction offset : Iterate.horizontalDirections) {
|
||||
BlockPos toUpdate = worldPosition.above()
|
||||
.relative(offset);
|
||||
BlockState stateToUpdate = level.getBlockState(toUpdate);
|
||||
if (stateToUpdate.getBlock() instanceof DistilleryControllerBlock) {
|
||||
BlockEntity be = level.getBlockEntity(toUpdate);
|
||||
if (be instanceof DistilleryControllerBlockEntity)
|
||||
((DistilleryControllerBlockEntity) be).contentsChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected Optional<FluidProcessingBlockEntity> getOperator() {
|
||||
if (level == null)
|
||||
return Optional.empty();
|
||||
BlockEntity te = level.getBlockEntity(worldPosition.above());
|
||||
if (te instanceof FluidProcessingBlockEntity)
|
||||
return Optional.of((FluidProcessingBlockEntity) te);
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void notifyChangeOfContents() {
|
||||
contentsChanged = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public SmartInventory getOutputInventory() {
|
||||
return outputInventory;
|
||||
}
|
||||
|
||||
|
||||
public static BlazeBurnerBlock.HeatLevel getHeatLevelOf(BlockState state) {
|
||||
if (state.hasProperty(BlazeBurnerBlock.HEAT_LEVEL))
|
||||
return state.getValue(BlazeBurnerBlock.HEAT_LEVEL);
|
||||
return AllTags.AllBlockTags.PASSIVE_BOILER_HEATERS.matches(state) ? BlazeBurnerBlock.HeatLevel.SMOULDERING : BlazeBurnerBlock.HeatLevel.NONE;
|
||||
}
|
||||
|
||||
public Couple<SmartFluidTankBehaviour> getTanks() {
|
||||
return tanks;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
|
||||
return containedFluidTooltip(tooltip, isPlayerSneaking,
|
||||
getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillery;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.block.IBE;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
|
||||
public class DistilleryOutputBlock extends Block implements IBE<DistilleryOutputBlockEntity> {
|
||||
|
||||
public DistilleryOutputBlock(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) {
|
||||
return !AllBlocks.BASIN.has(worldIn.getBlockState(pos.below()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<DistilleryOutputBlockEntity> getBlockEntityClass() {
|
||||
return DistilleryOutputBlockEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends DistilleryOutputBlockEntity> getBlockEntityType() {
|
||||
return TFMGBlockEntities.CAST_IRON_DISTILLATION_OUTPUT.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,406 +0,0 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillery;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.FluidProcessingBlockEntity;
|
||||
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillation_tower.DistillationControllerBlockEntity;
|
||||
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillation_tower.DistillationOutputBlockEntity;
|
||||
import com.drmangotea.createindustry.recipes.distillation.AbstractDistillationRecipe;
|
||||
import com.drmangotea.createindustry.recipes.distillation.DistillationRecipe;
|
||||
import com.drmangotea.createindustry.registry.TFMGRecipeTypes;
|
||||
import com.simibubi.create.AllRecipeTypes;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.content.kinetics.press.MechanicalPressBlockEntity;
|
||||
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock;
|
||||
import com.simibubi.create.content.processing.burner.BlazeBurnerBlockEntity;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
import com.simibubi.create.foundation.fluid.SmartFluidTank;
|
||||
import com.simibubi.create.foundation.recipe.RecipeFinder;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.crafting.IShapedRecipe;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DistilleryOutputBlockEntity extends FluidProcessingBlockEntity implements IHaveGoggleInformation {
|
||||
|
||||
protected LazyOptional<IFluidHandler> fluidCapability;
|
||||
public FluidTank tankInventory;
|
||||
protected BlockPos lastKnownPos;
|
||||
|
||||
private static final int SYNC_RATE = 8;
|
||||
protected int syncCooldown;
|
||||
protected boolean queuedSync;
|
||||
|
||||
|
||||
private static final Object DistillationRecipesKey = new Object();
|
||||
|
||||
public boolean running;
|
||||
|
||||
public DistilleryOutputBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
tankInventory = createInventory();
|
||||
fluidCapability = LazyOptional.of(() -> tankInventory);
|
||||
refreshCapability();
|
||||
}
|
||||
|
||||
protected <C extends Container> boolean matchItemlessRecipe(Recipe<C> recipe) {
|
||||
if (recipe == null)
|
||||
return false;
|
||||
Optional<DistilleryControllerBlockEntity> controller = getController();
|
||||
if (!controller.isPresent())
|
||||
return false;
|
||||
return DistillationRecipe.match(controller.get(), recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean updateController() {
|
||||
|
||||
|
||||
if (level == null || level.isClientSide)
|
||||
return true;
|
||||
|
||||
|
||||
recipe = getMatchingRecipes();
|
||||
startProcessing();
|
||||
sendData();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
|
||||
super.addBehaviours(behaviours);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AABB createRenderBoundingBox() {
|
||||
return new AABB(worldPosition).expandTowards(0, -1.5, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void read(CompoundTag compound, boolean clientPacket) {
|
||||
running = compound.getBoolean("Running");
|
||||
|
||||
super.read(compound, clientPacket);
|
||||
lastKnownPos = null;
|
||||
|
||||
if (compound.contains("LastKnownPos"))
|
||||
lastKnownPos = NbtUtils.readBlockPos(compound.getCompound("LastKnownPos"));
|
||||
|
||||
|
||||
tankInventory.setCapacity(8000);
|
||||
tankInventory.readFromNBT(compound.getCompound("TankContent"));
|
||||
if (tankInventory.getSpace() < 0)
|
||||
tankInventory.drain(-tankInventory.getSpace(), IFluidHandler.FluidAction.EXECUTE);
|
||||
|
||||
}
|
||||
@Override
|
||||
public void write(CompoundTag compound, boolean clientPacket) {
|
||||
compound.putBoolean("Running", running);
|
||||
if (lastKnownPos != null)
|
||||
compound.put("LastKnownPos", NbtUtils.writeBlockPos(lastKnownPos));
|
||||
|
||||
compound.put("TankContent", tankInventory.writeToNBT(new CompoundTag()));
|
||||
|
||||
super.write(compound, clientPacket);
|
||||
super.write(compound, clientPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if(this instanceof DistillationOutputBlockEntity)
|
||||
return;
|
||||
|
||||
|
||||
if (level != null) {
|
||||
if ((!level.isClientSide || isVirtual())) {
|
||||
process();
|
||||
sendData();
|
||||
}
|
||||
}
|
||||
if (syncCooldown > 0) {
|
||||
syncCooldown--;
|
||||
if (syncCooldown == 0 && queuedSync)
|
||||
sendData();
|
||||
}
|
||||
}
|
||||
|
||||
protected void process() {
|
||||
updateController();
|
||||
|
||||
if (recipe == null)
|
||||
return;
|
||||
|
||||
// if((currentRecipe instanceof ShapelessRecipe))
|
||||
// return;
|
||||
|
||||
BlockEntity above1 = level.getBlockEntity(this.getBlockPos().above(1));
|
||||
BlockEntity above2 = level.getBlockEntity(this.getBlockPos().above(2));
|
||||
BlockEntity burner = level.getBlockEntity(this.getBlockPos().below(2));
|
||||
if(!(burner instanceof BlazeBurnerBlockEntity))
|
||||
return;
|
||||
if(((BlazeBurnerBlockEntity) burner).getHeatLevelFromBlock()== BlazeBurnerBlock.HeatLevel.NONE)
|
||||
return;
|
||||
if(((BlazeBurnerBlockEntity) burner).getHeatLevelFromBlock()== BlazeBurnerBlock.HeatLevel.SMOULDERING)
|
||||
return;
|
||||
|
||||
|
||||
if(above1 !=null&& above2 !=null
|
||||
// &&
|
||||
/// tankInventory.getFluidAmount()+
|
||||
/// ((DistillationRecipe)currentRecipe)
|
||||
/// .getFirstFluidResult()
|
||||
/// .getAmount()
|
||||
/// <8000&&
|
||||
// ((DistillationOutputBlockEntity) above1).tankInventory.getFluidAmount()+((DistillationRecipe)currentRecipe).getFluidResults().get(1).getAmount()<((DistillationOutputBlockEntity) above2).tankInventory.getCapacity()&&
|
||||
// ((DistillationOutputBlockEntity) above2).tankInventory.getFluidAmount()+((DistillationRecipe)currentRecipe).getFluidResults().get(2).getAmount()<((DistillationOutputBlockEntity) above2).tankInventory.getCapacity()
|
||||
){
|
||||
Optional<DistilleryControllerBlockEntity> optionalController = getController();
|
||||
if (!optionalController.isPresent())
|
||||
return;
|
||||
|
||||
if(!(above1 instanceof DistilleryOutputBlockEntity)&&
|
||||
!( above2 instanceof DistilleryOutputBlockEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(above1 instanceof DistilleryOutputBlockEntity))
|
||||
return;
|
||||
if(!(above2 instanceof DistilleryOutputBlockEntity))
|
||||
return;
|
||||
|
||||
|
||||
FluidStack fluidInRecipe1 = ((DistillationRecipe) recipe).getFirstFluidResult();
|
||||
FluidStack fluidInRecipe2 = ((DistillationRecipe) recipe).getSecondFluidResult();
|
||||
FluidStack fluidInRecipe3 = ((DistillationRecipe) recipe).getThirdFluidResult();
|
||||
|
||||
|
||||
|
||||
|
||||
if (fluidInRecipe1.getFluid() != this.tankInventory.getFluid().getFluid()
|
||||
&& tankInventory.getFluidAmount()!=0
|
||||
)
|
||||
return;
|
||||
|
||||
if (fluidInRecipe2.getFluid() != (((DistilleryOutputBlockEntity) above1).tankInventory.getFluid().getFluid())
|
||||
&&((DistilleryOutputBlockEntity) above1).tankInventory.getFluidAmount()!=0
|
||||
)
|
||||
return;
|
||||
if (fluidInRecipe3.getFluid() != (((DistilleryOutputBlockEntity) above2).tankInventory.getFluid().getFluid())
|
||||
&&((DistilleryOutputBlockEntity) above2).tankInventory.getFluidAmount()!=0
|
||||
)
|
||||
return;
|
||||
|
||||
if(
|
||||
tankInventory.getFluidAmount()+((DistillationRecipe) recipe).getFirstFluidResult().getAmount()>8000||
|
||||
((DistilleryOutputBlockEntity)above1).tankInventory.getFluidAmount()+((DistillationRecipe) recipe).getFirstFluidResult().getAmount()>8000||
|
||||
((DistilleryOutputBlockEntity)above2).tankInventory.getFluidAmount()+((DistillationRecipe) recipe).getFirstFluidResult().getAmount()>8000
|
||||
)
|
||||
return;
|
||||
|
||||
|
||||
if(getController().get().getTanks().get(true).getPrimaryHandler().getFluid().getFluid() != ((DistillationRecipe) recipe).getInputFluid().getMatchingFluidStacks().get(0).getFluid())
|
||||
return;
|
||||
|
||||
DistilleryControllerBlockEntity controller = optionalController.get();
|
||||
|
||||
|
||||
if(controller.outputInventory.getStackInSlot(0).getCount()>=1||
|
||||
controller.outputInventory.getStackInSlot(1).getCount()>=1||
|
||||
controller.outputInventory.getStackInSlot(2).getCount()>=1)
|
||||
return;
|
||||
|
||||
if (!controller.getTanks().get(true).isEmpty()) {
|
||||
if(!level.isClientSide) {
|
||||
// if(((DistillationRecipe)currentRecipe).getInputFluid().getMatchingFluidStacks().get(0).getFluid() != TFMGFluids.HEAVY_OIL.get())
|
||||
// return;
|
||||
|
||||
controller.getTanks().get(true).getPrimaryHandler().drain(((DistillationRecipe) recipe).getFluidIngredients().get(0).getRequiredAmount(), IFluidHandler.FluidAction.EXECUTE);
|
||||
|
||||
if (!(((DistillationRecipe) recipe).getFluidResults().get(0).isEmpty()))
|
||||
tankInventory.setFluid(new FluidStack(((DistillationRecipe) recipe).getFluidResults().get(0).getFluid(), ((DistillationRecipe) recipe).getFluidResults().get(0).getAmount() + this.tankInventory.getFluidAmount()));
|
||||
if (!(((DistillationRecipe) recipe).getFluidResults().get(1).isEmpty()))
|
||||
((DistilleryOutputBlockEntity) above1).tankInventory.setFluid(new FluidStack(((DistillationRecipe) recipe).getFluidResults().get(1).getFluid(), ((DistillationRecipe) recipe).getFluidResults().get(1).getAmount() + ((DistilleryOutputBlockEntity) above1).tankInventory.getFluidAmount()));
|
||||
if (!(((DistillationRecipe) recipe).getFluidResults().get(2).isEmpty()))
|
||||
((DistilleryOutputBlockEntity) above2).tankInventory.setFluid(new FluidStack(((DistillationRecipe) recipe).getFluidResults().get(2).getFluid(), ((DistillationRecipe) recipe).getFluidResults().get(2).getAmount() + ((DistilleryOutputBlockEntity) above2).tankInventory.getFluidAmount()));
|
||||
|
||||
|
||||
if (!(((DistillationRecipe) recipe).getFirstItemResult().isEmpty()))
|
||||
controller.outputInventory.setItem(0, ((DistillationRecipe) recipe).getFirstItemResult());
|
||||
|
||||
if (!(((DistillationRecipe) recipe).getSecondItemResult().isEmpty()))
|
||||
controller.outputInventory.setItem(1, ((DistillationRecipe) recipe).getSecondItemResult());
|
||||
}
|
||||
/*
|
||||
if(!(((DistillationRecipe) currentRecipe).getThirdItemResult().isEmpty()))
|
||||
controller.outputInventory.setItem(2,((DistillationRecipe) currentRecipe).getFirstItemResult());
|
||||
|
||||
|
||||
*/
|
||||
|
||||
controller.notifyChangeOfContents();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected DistillationRecipe getMatchingRecipes() {
|
||||
|
||||
DistilleryControllerBlockEntity be=null;
|
||||
|
||||
if(level.getBlockEntity(getBlockPos().below())instanceof DistilleryControllerBlockEntity)
|
||||
be = (DistilleryControllerBlockEntity) level.getBlockEntity(getBlockPos().below());
|
||||
|
||||
if(be==null)
|
||||
return null;
|
||||
|
||||
List<Recipe<?>> list = RecipeFinder.get(getRecipeCacheKey(), level, this::matchStaticFilters);
|
||||
|
||||
|
||||
for(int i = 0; i < list.toArray().length;i++){
|
||||
DistillationRecipe recipe = (DistillationRecipe) list.get(i);
|
||||
for(int y = 0; y < recipe.getFluidIngredients().get(0).getMatchingFluidStacks().toArray().length;y++)
|
||||
if(be.inputTank.getPrimaryHandler().getFluid().getFluid()==recipe.getFluidIngredients().get(0).getMatchingFluidStacks().get(y).getFluid())
|
||||
if(be.inputTank.getPrimaryHandler().getFluidAmount()>=recipe.getFluidIngredients().get(0).getRequiredAmount())
|
||||
return recipe;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected <C extends Container> boolean matchStaticFilters(Recipe<C> r) {
|
||||
return r instanceof DistillationRecipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startProcessing() {
|
||||
if (running )
|
||||
return;
|
||||
super.startProcessing();
|
||||
running = true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean continueWithPreviousRecipe() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onControllerRemoved() {
|
||||
if (!running)
|
||||
return;
|
||||
|
||||
running = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getRecipeCacheKey() {
|
||||
return DistillationRecipesKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isRunning() {
|
||||
return running;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected SmartFluidTank createInventory() {
|
||||
return new SmartFluidTank(8000, this::onFluidStackChanged);
|
||||
}
|
||||
|
||||
|
||||
protected void onFluidStackChanged(FluidStack newFluidStack) {
|
||||
if (!hasLevel())
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendData() {
|
||||
if (syncCooldown > 0) {
|
||||
queuedSync = true;
|
||||
return;
|
||||
}
|
||||
super.sendData();
|
||||
queuedSync = false;
|
||||
syncCooldown = SYNC_RATE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void refreshCapability() {
|
||||
LazyOptional<IFluidHandler> oldCap = fluidCapability;
|
||||
fluidCapability = LazyOptional.of(() -> handlerForCapability());
|
||||
oldCap.invalidate();
|
||||
}
|
||||
|
||||
private IFluidHandler handlerForCapability() {
|
||||
|
||||
return tankInventory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
|
||||
|
||||
return containedFluidTooltip(tooltip, isPlayerSneaking,
|
||||
this.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@SuppressWarnings("removal")
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
|
||||
if (!fluidCapability.isPresent())
|
||||
refreshCapability();
|
||||
if (cap == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
||||
return fluidCapability.cast();
|
||||
return super.getCapability(cap, side);
|
||||
}
|
||||
|
||||
|
||||
public IFluidTank getTankInventory() {
|
||||
return tankInventory;
|
||||
}
|
||||
|
||||
|
||||
public FluidStack getFluid(int tank) {
|
||||
return tankInventory.getFluid()
|
||||
.copy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.pumpjack.base;
|
||||
|
||||
import com.drmangotea.createindustry.CreateTFMG;
|
||||
import com.drmangotea.createindustry.blocks.deposits.FluidDepositBlockEntity;
|
||||
import com.drmangotea.createindustry.blocks.machines.oil_processing.pumpjack.crank.PumpjackCrankBlockEntity;
|
||||
import com.drmangotea.createindustry.blocks.machines.oil_processing.pumpjack.hammer.PumpjackBlockEntity;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
@@ -20,9 +18,9 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
|
||||
@@ -42,7 +40,7 @@ public class PumpjackBaseBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
|
||||
protected LazyOptional<IFluidHandler> fluidCapability;
|
||||
public FluidTank tankInventory;
|
||||
public FluidDepositBlockEntity deposit;
|
||||
public BlockPos deposit;
|
||||
|
||||
public PumpjackBaseBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
@@ -119,7 +117,7 @@ public class PumpjackBaseBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
BlockPos checkedPos = new BlockPos(this.getBlockPos().getX(), (this.getBlockPos().getY() - 1) - i, this.getBlockPos().getZ());
|
||||
|
||||
if (level.getBlockState(new BlockPos(checkedPos)).is(TFMGBlocks.OIL_DEPOSIT.get())) {
|
||||
deposit = (FluidDepositBlockEntity) level.getBlockEntity(checkedPos);
|
||||
deposit = checkedPos;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -134,15 +132,14 @@ public class PumpjackBaseBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
|
||||
}
|
||||
public void process() {
|
||||
if (deposit == null || deposit.fluidAmount == 0)
|
||||
if (deposit == null)
|
||||
return;
|
||||
|
||||
if (tankInventory.getFluidAmount() + miningRate > 8000)
|
||||
return;
|
||||
|
||||
deposit.fluidAmount -= miningRate;
|
||||
|
||||
tankInventory.setFluid(new FluidStack(deposit.getDepositFluid(), tankInventory.getFluidAmount() + miningRate));
|
||||
tankInventory.setFluid(new FluidStack(TFMGFluids.CRUDE_OIL.getSource(), tankInventory.getFluidAmount() + miningRate));
|
||||
|
||||
}
|
||||
|
||||
@@ -173,26 +170,14 @@ public class PumpjackBaseBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
LangBuilder mb = Lang.translate("generic.unit.millibuckets");
|
||||
|
||||
|
||||
Lang.translate("goggles.pumpjack.deposit_info")
|
||||
.style(ChatFormatting.GRAY)
|
||||
.forGoggles(tooltip);
|
||||
|
||||
|
||||
if (!(deposit == null || deposit.fluidAmount == 0)) {
|
||||
Lang.translate("goggles.pumpjack.fluid_amount")
|
||||
.style(ChatFormatting.DARK_GRAY)
|
||||
.add(
|
||||
Lang.translate("pumpjack_deposit_amount", this.deposit.baseFluidAmount)
|
||||
.style(ChatFormatting.BLUE)
|
||||
// .add(mb))
|
||||
).forGoggles(tooltip, 1);
|
||||
|
||||
//Lang.translate("pumpjack_deposit_amount", this.miningRate)
|
||||
// .style(ChatFormatting.LIGHT_PURPLE)
|
||||
// .forGoggles(tooltip, 1);
|
||||
|
||||
Lang.translate("pumpjack_deposit_amount", this.miningRate)
|
||||
.style(ChatFormatting.LIGHT_PURPLE)
|
||||
.forGoggles(tooltip, 1);
|
||||
|
||||
} else {
|
||||
if (deposit == null) {
|
||||
|
||||
Lang.translate("goggles.zero")
|
||||
.style(ChatFormatting.DARK_RED)
|
||||
@@ -200,7 +185,7 @@ public class PumpjackBaseBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
}
|
||||
|
||||
//--Fluid Info--//
|
||||
LazyOptional<IFluidHandler> handler = this.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY);
|
||||
LazyOptional<IFluidHandler> handler = this.getCapability(ForgeCapabilities.FLUID_HANDLER);
|
||||
Optional<IFluidHandler> resolve = handler.resolve();
|
||||
if (!resolve.isPresent())
|
||||
return false;
|
||||
@@ -273,10 +258,10 @@ public class PumpjackBaseBlockEntity extends SmartBlockEntity implements IHaveGo
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, Direction side) {
|
||||
|
||||
if (cap == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
||||
if (cap == ForgeCapabilities.FLUID_HANDLER)
|
||||
return fluidCapability.cast();
|
||||
return super.getCapability(cap, side);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.pumpjack.hammer;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGContraptions;
|
||||
import com.drmangotea.createindustry.registry.TFMGContraptions;
|
||||
import com.simibubi.create.content.contraptions.AssemblyException;
|
||||
import com.simibubi.create.content.contraptions.ContraptionType;
|
||||
import com.simibubi.create.content.contraptions.bearing.AnchoredLighter;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.drmangotea.createindustry.blocks.pipes.normal.aluminum;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.blocks.pipes.normal.LockablePipeBlockEntity;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.decoration.bracket.BracketedBlockEntityBehaviour;
|
||||
import com.simibubi.create.content.fluids.FluidPropagator;
|
||||
@@ -151,7 +152,7 @@ public class AluminumPipeBlock extends FluidPipeBlock {
|
||||
.ifPresent($ -> AllAdvancements.GLASS_PIPE.awardTo(context.getPlayer())));
|
||||
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
world.setBlockAndUpdate(pos, TFMGBlocks.GLASS_ALUMINUM_PIPE.getDefaultState()
|
||||
world.setBlockAndUpdate(pos, TFMGPipes.GLASS_ALUMINUM_PIPE.getDefaultState()
|
||||
.setValue(GlassFluidPipeBlock.AXIS, axis)
|
||||
.setValue(BlockStateProperties.WATERLOGGED, state.getValue(BlockStateProperties.WATERLOGGED)));
|
||||
FluidTransportBehaviour.loadFlows(world, pos);
|
||||
@@ -165,7 +166,7 @@ public class AluminumPipeBlock extends FluidPipeBlock {
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos,
|
||||
Player player) {
|
||||
return TFMGBlocks.ALUMINUM_PIPE.asStack();
|
||||
return TFMGPipes.ALUMINUM_PIPE.asStack();
|
||||
}
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
||||
@@ -177,7 +178,7 @@ public class AluminumPipeBlock extends FluidPipeBlock {
|
||||
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
world.setBlockAndUpdate(pos,
|
||||
EncasedPipeBlock.transferSixWayProperties(state, TFMGBlocks.COPPER_ENCASED_ALUMINUM_PIPE.getDefaultState()));
|
||||
EncasedPipeBlock.transferSixWayProperties(state, TFMGPipes.COPPER_ENCASED_ALUMINUM_PIPE.getDefaultState()));
|
||||
FluidTransportBehaviour.loadFlows(world, pos);
|
||||
return InteractionResult.SUCCESS;
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.drmangotea.createindustry.blocks.pipes.normal.aluminum;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
|
||||
import com.simibubi.create.content.fluids.FluidTransportBehaviour;
|
||||
import com.simibubi.create.content.fluids.pipes.EncasedPipeBlock;
|
||||
import com.simibubi.create.content.fluids.pipes.FluidPipeBlockEntity;
|
||||
@@ -30,7 +31,7 @@ public class EncasedAluminumPipeBlock extends EncasedPipeBlock {
|
||||
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player) {
|
||||
return TFMGBlocks.ALUMINUM_PIPE.asStack();
|
||||
return TFMGPipes.ALUMINUM_PIPE.asStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +44,7 @@ public class EncasedAluminumPipeBlock extends EncasedPipeBlock {
|
||||
|
||||
context.getLevel()
|
||||
.levelEvent(2001, context.getClickedPos(), Block.getId(state));
|
||||
BlockState equivalentPipe = transferSixWayProperties(state, TFMGBlocks.ALUMINUM_PIPE.getDefaultState());
|
||||
BlockState equivalentPipe = transferSixWayProperties(state, TFMGPipes.ALUMINUM_PIPE.getDefaultState());
|
||||
|
||||
Direction firstFound = Direction.UP;
|
||||
for (Direction d : Iterate.directions)
|
||||
@@ -53,7 +54,7 @@ public class EncasedAluminumPipeBlock extends EncasedPipeBlock {
|
||||
}
|
||||
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
world.setBlockAndUpdate(pos, TFMGBlocks.ALUMINUM_PIPE.get()
|
||||
world.setBlockAndUpdate(pos, TFMGPipes.ALUMINUM_PIPE.get()
|
||||
.updateBlockState(equivalentPipe, firstFound, null, world, pos));
|
||||
FluidTransportBehaviour.loadFlows(world, pos);
|
||||
return InteractionResult.SUCCESS;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.drmangotea.createindustry.blocks.pipes.normal.aluminum;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.fluids.FluidTransportBehaviour;
|
||||
import com.simibubi.create.content.fluids.pipes.EncasedPipeBlock;
|
||||
@@ -36,19 +37,19 @@ public class GlassAluminumPipeBlock extends GlassFluidPipeBlock {
|
||||
|
||||
@Override
|
||||
public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) {
|
||||
return ItemRequirement.of(TFMGBlocks.ALUMINUM_PIPE.getDefaultState(), te);
|
||||
return ItemRequirement.of(TFMGPipes.ALUMINUM_PIPE.getDefaultState(), te);
|
||||
}
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos,
|
||||
Player player) {
|
||||
return TFMGBlocks.ALUMINUM_PIPE.asStack();
|
||||
return TFMGPipes.ALUMINUM_PIPE.asStack();
|
||||
}
|
||||
@Override
|
||||
public BlockState toRegularPipe(LevelAccessor world, BlockPos pos, BlockState state) {
|
||||
Direction side = Direction.get(Direction.AxisDirection.POSITIVE, state.getValue(AXIS));
|
||||
Map<Direction, BooleanProperty> facingToPropertyMap = FluidPipeBlock.PROPERTY_BY_DIRECTION;
|
||||
return TFMGBlocks.ALUMINUM_PIPE.get()
|
||||
.updateBlockState(TFMGBlocks.ALUMINUM_PIPE.getDefaultState()
|
||||
return TFMGPipes.ALUMINUM_PIPE.get()
|
||||
.updateBlockState(TFMGPipes.ALUMINUM_PIPE.getDefaultState()
|
||||
.setValue(facingToPropertyMap.get(side), true)
|
||||
.setValue(facingToPropertyMap.get(side.getOpposite()), true), side, null, world, pos);
|
||||
}
|
||||
@@ -59,7 +60,7 @@ public class GlassAluminumPipeBlock extends GlassFluidPipeBlock {
|
||||
return InteractionResult.PASS;
|
||||
if (world.isClientSide)
|
||||
return InteractionResult.SUCCESS;
|
||||
BlockState newState = TFMGBlocks.COPPER_ENCASED_ALUMINUM_PIPE.getDefaultState();
|
||||
BlockState newState = TFMGPipes.COPPER_ENCASED_ALUMINUM_PIPE.getDefaultState();
|
||||
for (Direction d : Iterate.directionsInAxis(getAxis(state)))
|
||||
newState = newState.setValue(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(d), true);
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.drmangotea.createindustry.blocks.pipes.normal.brass;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.blocks.pipes.normal.LockablePipeBlockEntity;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.decoration.bracket.BracketedBlockEntityBehaviour;
|
||||
import com.simibubi.create.content.fluids.FluidPropagator;
|
||||
@@ -151,7 +152,7 @@ public class BrassPipeBlock extends FluidPipeBlock {
|
||||
.ifPresent($ -> AllAdvancements.GLASS_PIPE.awardTo(context.getPlayer())));
|
||||
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
world.setBlockAndUpdate(pos, TFMGBlocks.GLASS_BRASS_PIPE.getDefaultState()
|
||||
world.setBlockAndUpdate(pos, TFMGPipes.GLASS_BRASS_PIPE.getDefaultState()
|
||||
.setValue(GlassFluidPipeBlock.AXIS, axis)
|
||||
.setValue(BlockStateProperties.WATERLOGGED, state.getValue(BlockStateProperties.WATERLOGGED)));
|
||||
FluidTransportBehaviour.loadFlows(world, pos);
|
||||
@@ -165,7 +166,7 @@ public class BrassPipeBlock extends FluidPipeBlock {
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos,
|
||||
Player player) {
|
||||
return TFMGBlocks.BRASS_PIPE.asStack();
|
||||
return TFMGPipes.BRASS_PIPE.asStack();
|
||||
}
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
||||
@@ -177,7 +178,7 @@ public class BrassPipeBlock extends FluidPipeBlock {
|
||||
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
world.setBlockAndUpdate(pos,
|
||||
EncasedPipeBlock.transferSixWayProperties(state, TFMGBlocks.COPPER_ENCASED_BRASS_PIPE.getDefaultState()));
|
||||
EncasedPipeBlock.transferSixWayProperties(state, TFMGPipes.COPPER_ENCASED_BRASS_PIPE.getDefaultState()));
|
||||
FluidTransportBehaviour.loadFlows(world, pos);
|
||||
return InteractionResult.SUCCESS;
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.drmangotea.createindustry.blocks.pipes.normal.brass;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
|
||||
import com.simibubi.create.content.fluids.FluidTransportBehaviour;
|
||||
import com.simibubi.create.content.fluids.pipes.EncasedPipeBlock;
|
||||
import com.simibubi.create.content.fluids.pipes.FluidPipeBlockEntity;
|
||||
@@ -30,7 +31,7 @@ public class EncasedBrassPipeBlock extends EncasedPipeBlock {
|
||||
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player) {
|
||||
return TFMGBlocks.BRASS_PIPE.asStack();
|
||||
return TFMGPipes.BRASS_PIPE.asStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +44,7 @@ public class EncasedBrassPipeBlock extends EncasedPipeBlock {
|
||||
|
||||
context.getLevel()
|
||||
.levelEvent(2001, context.getClickedPos(), Block.getId(state));
|
||||
BlockState equivalentPipe = transferSixWayProperties(state, TFMGBlocks.BRASS_PIPE.getDefaultState());
|
||||
BlockState equivalentPipe = transferSixWayProperties(state, TFMGPipes.BRASS_PIPE.getDefaultState());
|
||||
|
||||
Direction firstFound = Direction.UP;
|
||||
for (Direction d : Iterate.directions)
|
||||
@@ -53,7 +54,7 @@ public class EncasedBrassPipeBlock extends EncasedPipeBlock {
|
||||
}
|
||||
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
world.setBlockAndUpdate(pos, TFMGBlocks.BRASS_PIPE.get()
|
||||
world.setBlockAndUpdate(pos, TFMGPipes.BRASS_PIPE.get()
|
||||
.updateBlockState(equivalentPipe, firstFound, null, world, pos));
|
||||
FluidTransportBehaviour.loadFlows(world, pos);
|
||||
return InteractionResult.SUCCESS;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.drmangotea.createindustry.blocks.pipes.normal.brass;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.fluids.FluidTransportBehaviour;
|
||||
import com.simibubi.create.content.fluids.pipes.EncasedPipeBlock;
|
||||
@@ -36,19 +37,19 @@ public class GlassBrassPipeBlock extends GlassFluidPipeBlock {
|
||||
|
||||
@Override
|
||||
public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) {
|
||||
return ItemRequirement.of(TFMGBlocks.BRASS_PIPE.getDefaultState(), te);
|
||||
return ItemRequirement.of(TFMGPipes.BRASS_PIPE.getDefaultState(), te);
|
||||
}
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos,
|
||||
Player player) {
|
||||
return TFMGBlocks.BRASS_PIPE.asStack();
|
||||
return TFMGPipes.BRASS_PIPE.asStack();
|
||||
}
|
||||
@Override
|
||||
public BlockState toRegularPipe(LevelAccessor world, BlockPos pos, BlockState state) {
|
||||
Direction side = Direction.get(Direction.AxisDirection.POSITIVE, state.getValue(AXIS));
|
||||
Map<Direction, BooleanProperty> facingToPropertyMap = FluidPipeBlock.PROPERTY_BY_DIRECTION;
|
||||
return TFMGBlocks.BRASS_PIPE.get()
|
||||
.updateBlockState(TFMGBlocks.BRASS_PIPE.getDefaultState()
|
||||
return TFMGPipes.BRASS_PIPE.get()
|
||||
.updateBlockState(TFMGPipes.BRASS_PIPE.getDefaultState()
|
||||
.setValue(facingToPropertyMap.get(side), true)
|
||||
.setValue(facingToPropertyMap.get(side.getOpposite()), true), side, null, world, pos);
|
||||
}
|
||||
@@ -59,7 +60,7 @@ public class GlassBrassPipeBlock extends GlassFluidPipeBlock {
|
||||
return InteractionResult.PASS;
|
||||
if (world.isClientSide)
|
||||
return InteractionResult.SUCCESS;
|
||||
BlockState newState = TFMGBlocks.COPPER_ENCASED_BRASS_PIPE.getDefaultState();
|
||||
BlockState newState = TFMGPipes.COPPER_ENCASED_BRASS_PIPE.getDefaultState();
|
||||
for (Direction d : Iterate.directionsInAxis(getAxis(state)))
|
||||
newState = newState.setValue(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(d), true);
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.drmangotea.createindustry.blocks.pipes.normal.cast_iron;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.blocks.pipes.normal.LockablePipeBlockEntity;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.decoration.bracket.BracketedBlockEntityBehaviour;
|
||||
import com.simibubi.create.content.fluids.FluidPropagator;
|
||||
@@ -151,7 +152,7 @@ public class CastIronPipeBlock extends FluidPipeBlock {
|
||||
.ifPresent($ -> AllAdvancements.GLASS_PIPE.awardTo(context.getPlayer())));
|
||||
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
world.setBlockAndUpdate(pos, TFMGBlocks.GLASS_CAST_IRON_PIPE.getDefaultState()
|
||||
world.setBlockAndUpdate(pos, TFMGPipes.GLASS_CAST_IRON_PIPE.getDefaultState()
|
||||
.setValue(GlassFluidPipeBlock.AXIS, axis)
|
||||
.setValue(BlockStateProperties.WATERLOGGED, state.getValue(BlockStateProperties.WATERLOGGED)));
|
||||
FluidTransportBehaviour.loadFlows(world, pos);
|
||||
@@ -165,7 +166,7 @@ public class CastIronPipeBlock extends FluidPipeBlock {
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos,
|
||||
Player player) {
|
||||
return TFMGBlocks.CAST_IRON_PIPE.asStack();
|
||||
return TFMGPipes.CAST_IRON_PIPE.asStack();
|
||||
}
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
||||
@@ -177,7 +178,7 @@ public class CastIronPipeBlock extends FluidPipeBlock {
|
||||
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
world.setBlockAndUpdate(pos,
|
||||
EncasedPipeBlock.transferSixWayProperties(state, TFMGBlocks.COPPER_ENCASED_CAST_IRON_PIPE.getDefaultState()));
|
||||
EncasedPipeBlock.transferSixWayProperties(state, TFMGPipes.COPPER_ENCASED_CAST_IRON_PIPE.getDefaultState()));
|
||||
FluidTransportBehaviour.loadFlows(world, pos);
|
||||
return InteractionResult.SUCCESS;
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.drmangotea.createindustry.blocks.pipes.normal.cast_iron;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
|
||||
import com.simibubi.create.content.fluids.FluidTransportBehaviour;
|
||||
import com.simibubi.create.content.fluids.pipes.EncasedPipeBlock;
|
||||
import com.simibubi.create.content.fluids.pipes.FluidPipeBlockEntity;
|
||||
@@ -30,7 +31,7 @@ public class EncasedCastIronPipeBlock extends EncasedPipeBlock {
|
||||
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player) {
|
||||
return TFMGBlocks.CAST_IRON_PIPE.asStack();
|
||||
return TFMGPipes.CAST_IRON_PIPE.asStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +44,7 @@ public class EncasedCastIronPipeBlock extends EncasedPipeBlock {
|
||||
|
||||
context.getLevel()
|
||||
.levelEvent(2001, context.getClickedPos(), Block.getId(state));
|
||||
BlockState equivalentPipe = transferSixWayProperties(state, TFMGBlocks.CAST_IRON_PIPE.getDefaultState());
|
||||
BlockState equivalentPipe = transferSixWayProperties(state, TFMGPipes.CAST_IRON_PIPE.getDefaultState());
|
||||
|
||||
Direction firstFound = Direction.UP;
|
||||
for (Direction d : Iterate.directions)
|
||||
@@ -53,7 +54,7 @@ public class EncasedCastIronPipeBlock extends EncasedPipeBlock {
|
||||
}
|
||||
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
world.setBlockAndUpdate(pos, TFMGBlocks.CAST_IRON_PIPE.get()
|
||||
world.setBlockAndUpdate(pos, TFMGPipes.CAST_IRON_PIPE.get()
|
||||
.updateBlockState(equivalentPipe, firstFound, null, world, pos));
|
||||
FluidTransportBehaviour.loadFlows(world, pos);
|
||||
return InteractionResult.SUCCESS;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.drmangotea.createindustry.blocks.pipes.normal.cast_iron;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.fluids.FluidTransportBehaviour;
|
||||
import com.simibubi.create.content.fluids.pipes.EncasedPipeBlock;
|
||||
@@ -36,19 +37,19 @@ public class GlassCastIronPipeBlock extends GlassFluidPipeBlock {
|
||||
|
||||
@Override
|
||||
public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) {
|
||||
return ItemRequirement.of(TFMGBlocks.CAST_IRON_PIPE.getDefaultState(), te);
|
||||
return ItemRequirement.of(TFMGPipes.CAST_IRON_PIPE.getDefaultState(), te);
|
||||
}
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos,
|
||||
Player player) {
|
||||
return TFMGBlocks.CAST_IRON_PIPE.asStack();
|
||||
return TFMGPipes.CAST_IRON_PIPE.asStack();
|
||||
}
|
||||
@Override
|
||||
public BlockState toRegularPipe(LevelAccessor world, BlockPos pos, BlockState state) {
|
||||
Direction side = Direction.get(Direction.AxisDirection.POSITIVE, state.getValue(AXIS));
|
||||
Map<Direction, BooleanProperty> facingToPropertyMap = FluidPipeBlock.PROPERTY_BY_DIRECTION;
|
||||
return TFMGBlocks.CAST_IRON_PIPE.get()
|
||||
.updateBlockState(TFMGBlocks.CAST_IRON_PIPE.getDefaultState()
|
||||
return TFMGPipes.CAST_IRON_PIPE.get()
|
||||
.updateBlockState(TFMGPipes.CAST_IRON_PIPE.getDefaultState()
|
||||
.setValue(facingToPropertyMap.get(side), true)
|
||||
.setValue(facingToPropertyMap.get(side.getOpposite()), true), side, null, world, pos);
|
||||
}
|
||||
@@ -59,7 +60,7 @@ public class GlassCastIronPipeBlock extends GlassFluidPipeBlock {
|
||||
return InteractionResult.PASS;
|
||||
if (world.isClientSide)
|
||||
return InteractionResult.SUCCESS;
|
||||
BlockState newState = TFMGBlocks.COPPER_ENCASED_CAST_IRON_PIPE.getDefaultState();
|
||||
BlockState newState = TFMGPipes.COPPER_ENCASED_CAST_IRON_PIPE.getDefaultState();
|
||||
for (Direction d : Iterate.directionsInAxis(getAxis(state)))
|
||||
newState = newState.setValue(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(d), true);
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.drmangotea.createindustry.blocks.pipes.normal.plastic;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
|
||||
import com.simibubi.create.content.fluids.FluidTransportBehaviour;
|
||||
import com.simibubi.create.content.fluids.pipes.EncasedPipeBlock;
|
||||
import com.simibubi.create.content.fluids.pipes.FluidPipeBlockEntity;
|
||||
@@ -30,7 +31,7 @@ public class EncasedPlasticPipeBlock extends EncasedPipeBlock {
|
||||
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player) {
|
||||
return TFMGBlocks.PLASTIC_PIPE.asStack();
|
||||
return TFMGPipes.PLASTIC_PIPE.asStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +44,7 @@ public class EncasedPlasticPipeBlock extends EncasedPipeBlock {
|
||||
|
||||
context.getLevel()
|
||||
.levelEvent(2001, context.getClickedPos(), Block.getId(state));
|
||||
BlockState equivalentPipe = transferSixWayProperties(state, TFMGBlocks.PLASTIC_PIPE.getDefaultState());
|
||||
BlockState equivalentPipe = transferSixWayProperties(state, TFMGPipes.PLASTIC_PIPE.getDefaultState());
|
||||
|
||||
Direction firstFound = Direction.UP;
|
||||
for (Direction d : Iterate.directions)
|
||||
@@ -53,7 +54,7 @@ public class EncasedPlasticPipeBlock extends EncasedPipeBlock {
|
||||
}
|
||||
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
world.setBlockAndUpdate(pos, TFMGBlocks.PLASTIC_PIPE.get()
|
||||
world.setBlockAndUpdate(pos, TFMGPipes.PLASTIC_PIPE.get()
|
||||
.updateBlockState(equivalentPipe, firstFound, null, world, pos));
|
||||
FluidTransportBehaviour.loadFlows(world, pos);
|
||||
return InteractionResult.SUCCESS;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.drmangotea.createindustry.blocks.pipes.normal.plastic;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.fluids.FluidTransportBehaviour;
|
||||
import com.simibubi.create.content.fluids.pipes.EncasedPipeBlock;
|
||||
@@ -36,19 +37,19 @@ public class GlassPlasticPipeBlock extends GlassFluidPipeBlock {
|
||||
|
||||
@Override
|
||||
public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) {
|
||||
return ItemRequirement.of(TFMGBlocks.PLASTIC_PIPE.getDefaultState(), te);
|
||||
return ItemRequirement.of(TFMGPipes.PLASTIC_PIPE.getDefaultState(), te);
|
||||
}
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos,
|
||||
Player player) {
|
||||
return TFMGBlocks.PLASTIC_PIPE.asStack();
|
||||
return TFMGPipes.PLASTIC_PIPE.asStack();
|
||||
}
|
||||
@Override
|
||||
public BlockState toRegularPipe(LevelAccessor world, BlockPos pos, BlockState state) {
|
||||
Direction side = Direction.get(Direction.AxisDirection.POSITIVE, state.getValue(AXIS));
|
||||
Map<Direction, BooleanProperty> facingToPropertyMap = FluidPipeBlock.PROPERTY_BY_DIRECTION;
|
||||
return TFMGBlocks.PLASTIC_PIPE.get()
|
||||
.updateBlockState(TFMGBlocks.PLASTIC_PIPE.getDefaultState()
|
||||
return TFMGPipes.PLASTIC_PIPE.get()
|
||||
.updateBlockState(TFMGPipes.PLASTIC_PIPE.getDefaultState()
|
||||
.setValue(facingToPropertyMap.get(side), true)
|
||||
.setValue(facingToPropertyMap.get(side.getOpposite()), true), side, null, world, pos);
|
||||
}
|
||||
@@ -59,7 +60,7 @@ public class GlassPlasticPipeBlock extends GlassFluidPipeBlock {
|
||||
return InteractionResult.PASS;
|
||||
if (world.isClientSide)
|
||||
return InteractionResult.SUCCESS;
|
||||
BlockState newState = TFMGBlocks.COPPER_ENCASED_PLASTIC_PIPE.getDefaultState();
|
||||
BlockState newState = TFMGPipes.COPPER_ENCASED_PLASTIC_PIPE.getDefaultState();
|
||||
for (Direction d : Iterate.directionsInAxis(getAxis(state)))
|
||||
newState = newState.setValue(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(d), true);
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.drmangotea.createindustry.blocks.pipes.normal.plastic;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.blocks.pipes.normal.LockablePipeBlockEntity;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.decoration.bracket.BracketedBlockEntityBehaviour;
|
||||
import com.simibubi.create.content.fluids.FluidPropagator;
|
||||
@@ -151,7 +151,7 @@ public class PlasticPipeBlock extends FluidPipeBlock {
|
||||
.ifPresent($ -> AllAdvancements.GLASS_PIPE.awardTo(context.getPlayer())));
|
||||
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
world.setBlockAndUpdate(pos, TFMGBlocks.GLASS_PLASTIC_PIPE.getDefaultState()
|
||||
world.setBlockAndUpdate(pos, TFMGPipes.GLASS_PLASTIC_PIPE.getDefaultState()
|
||||
.setValue(GlassFluidPipeBlock.AXIS, axis)
|
||||
.setValue(BlockStateProperties.WATERLOGGED, state.getValue(BlockStateProperties.WATERLOGGED)));
|
||||
FluidTransportBehaviour.loadFlows(world, pos);
|
||||
@@ -165,7 +165,7 @@ public class PlasticPipeBlock extends FluidPipeBlock {
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos,
|
||||
Player player) {
|
||||
return TFMGBlocks.PLASTIC_PIPE.asStack();
|
||||
return TFMGPipes.PLASTIC_PIPE.asStack();
|
||||
}
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
||||
@@ -177,7 +177,7 @@ public class PlasticPipeBlock extends FluidPipeBlock {
|
||||
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
world.setBlockAndUpdate(pos,
|
||||
EncasedPipeBlock.transferSixWayProperties(state, TFMGBlocks.COPPER_ENCASED_PLASTIC_PIPE.getDefaultState()));
|
||||
EncasedPipeBlock.transferSixWayProperties(state, TFMGPipes.COPPER_ENCASED_PLASTIC_PIPE.getDefaultState()));
|
||||
FluidTransportBehaviour.loadFlows(world, pos);
|
||||
return InteractionResult.SUCCESS;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.drmangotea.createindustry.blocks.pipes.normal.steel;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.simibubi.create.content.fluids.FluidTransportBehaviour;
|
||||
@@ -30,7 +31,7 @@ public class EncasedSteelPipeBlock extends EncasedPipeBlock {
|
||||
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player) {
|
||||
return TFMGBlocks.STEEL_PIPE.asStack();
|
||||
return TFMGPipes.STEEL_PIPE.asStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +44,7 @@ public class EncasedSteelPipeBlock extends EncasedPipeBlock {
|
||||
|
||||
context.getLevel()
|
||||
.levelEvent(2001, context.getClickedPos(), Block.getId(state));
|
||||
BlockState equivalentPipe = transferSixWayProperties(state, TFMGBlocks.STEEL_PIPE.getDefaultState());
|
||||
BlockState equivalentPipe = transferSixWayProperties(state, TFMGPipes.STEEL_PIPE.getDefaultState());
|
||||
|
||||
Direction firstFound = Direction.UP;
|
||||
for (Direction d : Iterate.directions)
|
||||
@@ -53,7 +54,7 @@ public class EncasedSteelPipeBlock extends EncasedPipeBlock {
|
||||
}
|
||||
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
world.setBlockAndUpdate(pos, TFMGBlocks.STEEL_PIPE.get()
|
||||
world.setBlockAndUpdate(pos, TFMGPipes.STEEL_PIPE.get()
|
||||
.updateBlockState(equivalentPipe, firstFound, null, world, pos));
|
||||
FluidTransportBehaviour.loadFlows(world, pos);
|
||||
return InteractionResult.SUCCESS;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.drmangotea.createindustry.blocks.pipes.normal.steel;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
@@ -36,19 +37,19 @@ public class GlassSteelPipeBlock extends GlassFluidPipeBlock {
|
||||
|
||||
@Override
|
||||
public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) {
|
||||
return ItemRequirement.of(TFMGBlocks.STEEL_PIPE.getDefaultState(), te);
|
||||
return ItemRequirement.of(TFMGPipes.STEEL_PIPE.getDefaultState(), te);
|
||||
}
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos,
|
||||
Player player) {
|
||||
return TFMGBlocks.STEEL_PIPE.asStack();
|
||||
return TFMGPipes.STEEL_PIPE.asStack();
|
||||
}
|
||||
@Override
|
||||
public BlockState toRegularPipe(LevelAccessor world, BlockPos pos, BlockState state) {
|
||||
Direction side = Direction.get(Direction.AxisDirection.POSITIVE, state.getValue(AXIS));
|
||||
Map<Direction, BooleanProperty> facingToPropertyMap = FluidPipeBlock.PROPERTY_BY_DIRECTION;
|
||||
return TFMGBlocks.STEEL_PIPE.get()
|
||||
.updateBlockState(TFMGBlocks.STEEL_PIPE.getDefaultState()
|
||||
return TFMGPipes.STEEL_PIPE.get()
|
||||
.updateBlockState(TFMGPipes.STEEL_PIPE.getDefaultState()
|
||||
.setValue(facingToPropertyMap.get(side), true)
|
||||
.setValue(facingToPropertyMap.get(side.getOpposite()), true), side, null, world, pos);
|
||||
}
|
||||
@@ -59,7 +60,7 @@ public class GlassSteelPipeBlock extends GlassFluidPipeBlock {
|
||||
return InteractionResult.PASS;
|
||||
if (world.isClientSide)
|
||||
return InteractionResult.SUCCESS;
|
||||
BlockState newState = TFMGBlocks.COPPER_ENCASED_STEEL_PIPE.getDefaultState();
|
||||
BlockState newState = TFMGPipes.COPPER_ENCASED_STEEL_PIPE.getDefaultState();
|
||||
for (Direction d : Iterate.directionsInAxis(getAxis(state)))
|
||||
newState = newState.setValue(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(d), true);
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.drmangotea.createindustry.blocks.pipes.normal.steel;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.blocks.pipes.normal.LockablePipeBlockEntity;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
@@ -151,7 +152,7 @@ public class SteelPipeBlock extends FluidPipeBlock {
|
||||
.ifPresent($ -> AllAdvancements.GLASS_PIPE.awardTo(context.getPlayer())));
|
||||
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
world.setBlockAndUpdate(pos, TFMGBlocks.GLASS_STEEL_PIPE.getDefaultState()
|
||||
world.setBlockAndUpdate(pos, TFMGPipes.GLASS_STEEL_PIPE.getDefaultState()
|
||||
.setValue(GlassFluidPipeBlock.AXIS, axis)
|
||||
.setValue(BlockStateProperties.WATERLOGGED, state.getValue(BlockStateProperties.WATERLOGGED)));
|
||||
FluidTransportBehaviour.loadFlows(world, pos);
|
||||
@@ -165,7 +166,7 @@ public class SteelPipeBlock extends FluidPipeBlock {
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos,
|
||||
Player player) {
|
||||
return TFMGBlocks.STEEL_PIPE.asStack();
|
||||
return TFMGPipes.STEEL_PIPE.asStack();
|
||||
}
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
||||
@@ -177,7 +178,7 @@ public class SteelPipeBlock extends FluidPipeBlock {
|
||||
|
||||
FluidTransportBehaviour.cacheFlows(world, pos);
|
||||
world.setBlockAndUpdate(pos,
|
||||
EncasedPipeBlock.transferSixWayProperties(state, TFMGBlocks.COPPER_ENCASED_STEEL_PIPE.getDefaultState()));
|
||||
EncasedPipeBlock.transferSixWayProperties(state, TFMGPipes.COPPER_ENCASED_STEEL_PIPE.getDefaultState()));
|
||||
FluidTransportBehaviour.loadFlows(world, pos);
|
||||
return InteractionResult.SUCCESS;
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ public class SteelFluidTankRenderer extends SafeBlockEntityRenderer<SteelTankBlo
|
||||
if (!te.isController())
|
||||
return;
|
||||
if (!te.window) {
|
||||
if (te.tower.isActive())
|
||||
renderAsBoiler(te, partialTicks, ms, buffer, light, overlay);
|
||||
if (te.isDistillationTower)
|
||||
renderAsDistillationTower(te, partialTicks, ms, buffer, light, overlay);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -78,8 +78,8 @@ public class SteelFluidTankRenderer extends SafeBlockEntityRenderer<SteelTankBlo
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
protected void renderAsBoiler(SteelTankBlockEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
protected void renderAsDistillationTower(SteelTankBlockEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
BlockState blockState = te.getBlockState();
|
||||
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
|
||||
ms.pushPose();
|
||||
@@ -87,7 +87,7 @@ public class SteelFluidTankRenderer extends SafeBlockEntityRenderer<SteelTankBlo
|
||||
msr.translate(te.width / 2f, 0.5, te.width / 2f);
|
||||
|
||||
float dialPivot = 5.75f / 16;
|
||||
float progress = te.tower.gauge.getValue(partialTicks);
|
||||
|
||||
|
||||
for (Direction d : Iterate.horizontalDirections) {
|
||||
ms.pushPose();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.drmangotea.createindustry.blocks.tanks;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.CreateTFMG;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.simibubi.create.api.connectivity.ConnectivityHandler;
|
||||
import com.simibubi.create.content.equipment.wrench.IWrenchable;
|
||||
@@ -335,17 +336,37 @@ public class SteelTankBlock extends Block implements IWrenchable, IBE<SteelTankB
|
||||
.orElse(0);
|
||||
}
|
||||
|
||||
public static void updateTowerState(BlockState pState, Level pLevel, BlockPos tankPos) {
|
||||
public static boolean updateTowerState(Level pLevel, BlockPos tankPos, boolean assemble,boolean simulate) {
|
||||
BlockState tankState = pLevel.getBlockState(tankPos);
|
||||
|
||||
if (!(tankState.getBlock()instanceof SteelTankBlock tank))
|
||||
return;
|
||||
SteelTankBlockEntity tankTE = tank.getBlockEntity(pLevel, tankPos);
|
||||
if (tankTE == null)
|
||||
return;
|
||||
SteelTankBlockEntity controllerTE = (SteelTankBlockEntity) tankTE.getControllerBE();
|
||||
if (controllerTE == null)
|
||||
return;
|
||||
controllerTE.updateBoilerState();
|
||||
return false;
|
||||
|
||||
SteelTankBlockEntity tankBE = tank.getBlockEntity(pLevel, tankPos);
|
||||
if (tankBE == null)
|
||||
return false;
|
||||
|
||||
if(assemble && tankBE.getControllerBE().isDistillationTower)
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
if(!simulate) {
|
||||
tankBE.getControllerBE().updateBoilerState();
|
||||
tankBE.getControllerBE().isDistillationTower = assemble;
|
||||
tankBE.getControllerBE().refreshCapability();
|
||||
|
||||
|
||||
tankBE.updateBoilerState();
|
||||
tankBE.isDistillationTower = assemble;
|
||||
tankBE.refreshCapability();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,31 +1,44 @@
|
||||
package com.drmangotea.createindustry.blocks.tanks;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillation_tower.DistillationTowerData;
|
||||
import com.drmangotea.createindustry.CreateTFMG;
|
||||
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.controller.DistillationControllerBlock;
|
||||
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.output.DistillationOutputBlock;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.api.connectivity.ConnectivityHandler;
|
||||
import com.simibubi.create.content.decoration.steamWhistle.WhistleBlock;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.content.fluids.tank.BoilerHeaters;
|
||||
import com.simibubi.create.content.fluids.tank.FluidTankBlock;
|
||||
import com.simibubi.create.content.fluids.tank.FluidTankBlockEntity;
|
||||
import com.simibubi.create.content.kinetics.steamEngine.SteamEngineBlock;
|
||||
import com.simibubi.create.foundation.blockEntity.IMultiBlockEntityContainer;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
import com.simibubi.create.foundation.fluid.SmartFluidTank;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
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 net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
@@ -53,7 +66,9 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
public int gaugeRotation=0;
|
||||
|
||||
|
||||
public DistillationTowerData tower;
|
||||
public int activeHeat;
|
||||
|
||||
public boolean isDistillationTower = false;
|
||||
|
||||
private static final int SYNC_RATE = 8;
|
||||
protected int syncCooldown;
|
||||
@@ -72,7 +87,7 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
window = true;
|
||||
height = 1;
|
||||
width = 1;
|
||||
tower = new DistillationTowerData();
|
||||
|
||||
refreshCapability();
|
||||
}
|
||||
|
||||
@@ -88,6 +103,9 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
return;
|
||||
if (!isController())
|
||||
return;
|
||||
|
||||
refreshCapability();
|
||||
|
||||
ConnectivityHandler.formMulti(this);
|
||||
}
|
||||
|
||||
@@ -96,6 +114,8 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
super.tick();
|
||||
getGaugeRotation();
|
||||
|
||||
updateTemperature();
|
||||
|
||||
visualGaugeRotation.chase(gaugeRotation, 0.2f, Chaser.EXP);
|
||||
visualGaugeRotation.tickChaser();
|
||||
if (syncCooldown > 0) {
|
||||
@@ -115,8 +135,7 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
updateConnectivity();
|
||||
if (fluidLevel != null)
|
||||
fluidLevel.tickChaser();
|
||||
if (isController())
|
||||
tower.tick(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -222,7 +241,7 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
controller = null;
|
||||
width = 1;
|
||||
height = 1;
|
||||
tower.clear();
|
||||
|
||||
onFluidStackChanged(tankInventory.getFluid());
|
||||
|
||||
BlockState state = getBlockState();
|
||||
@@ -242,19 +261,12 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
SteelTankBlockEntity te = getControllerBE();
|
||||
if (te == null)
|
||||
return;
|
||||
if (te.tower.isActive())
|
||||
if (isDistillationTower)
|
||||
return;
|
||||
te.setWindows(!te.window);
|
||||
}
|
||||
|
||||
public void updateBoilerTemperature() {
|
||||
SteelTankBlockEntity te = getControllerBE();
|
||||
if (te == null)
|
||||
return;
|
||||
if (!te.tower.isActive())
|
||||
return;
|
||||
te.tower.needsHeatLevelUpdate = true;
|
||||
}
|
||||
|
||||
|
||||
public void sendDataImmediately() {
|
||||
syncCooldown = 0;
|
||||
@@ -311,11 +323,11 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
if (!isController())
|
||||
return;
|
||||
|
||||
boolean wasBoiler = tower.isActive();
|
||||
boolean changed = tower.evaluate(this);
|
||||
boolean wasTower = isDistillationTower;
|
||||
boolean changed = evaluate();
|
||||
|
||||
if (wasBoiler != tower.isActive()) {
|
||||
if (tower.isActive())
|
||||
if (wasTower != isDistillationTower) {
|
||||
if (isDistillationTower)
|
||||
setWindows(false);
|
||||
|
||||
for (int yOffset = 0; yOffset < height; yOffset++)
|
||||
@@ -328,10 +340,74 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
|
||||
if (changed) {
|
||||
notifyUpdate();
|
||||
refreshCapability();
|
||||
|
||||
}
|
||||
}
|
||||
public boolean evaluate() {
|
||||
|
||||
boolean hadController = isDistillationTower;
|
||||
boolean foundController = false;
|
||||
|
||||
BlockPos pos1 = controller == null ? getBlockPos() : controller;
|
||||
|
||||
for (int yOffset = 0; yOffset < getControllerBE().height; yOffset++) {
|
||||
for (int xOffset = 0; xOffset < getControllerBE().width; xOffset++) {
|
||||
for (int zOffset = 0; zOffset < getControllerBE().width; zOffset++) {
|
||||
|
||||
BlockPos pos = pos1.offset(xOffset, yOffset, zOffset);
|
||||
BlockState blockState = level.getBlockState(pos);
|
||||
if (!SteelTankBlock.isTank(blockState))
|
||||
continue;
|
||||
for (Direction d : Iterate.directions) {
|
||||
BlockPos attachedPos = pos.relative(d);
|
||||
BlockState attachedState = level.getBlockState(attachedPos);
|
||||
|
||||
if (attachedState.is(TFMGBlocks.STEEL_DISTILLATION_CONTROLLER.get())) {
|
||||
|
||||
if(!foundController) {
|
||||
foundController = true;
|
||||
}else
|
||||
level.destroyBlock(attachedPos,true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
isDistillationTower = foundController;
|
||||
|
||||
return hadController != foundController;
|
||||
}
|
||||
|
||||
public void updateTemperature() {
|
||||
|
||||
int prevHeat = activeHeat;
|
||||
|
||||
activeHeat = 0;
|
||||
|
||||
BlockPos pos1 = controller == null ? getBlockPos() : controller;
|
||||
|
||||
SteelTankBlockEntity be = getControllerBE() == null ? this : getControllerBE();
|
||||
|
||||
for (int xOffset = 0; xOffset < be.width; xOffset++) {
|
||||
for (int zOffset = 0; zOffset < be.width; zOffset++) {
|
||||
BlockPos pos = pos1.offset(xOffset, -1, zOffset);
|
||||
BlockState blockState = level.getBlockState(pos);
|
||||
float heat = BoilerHeaters.getActiveHeat(level, pos, blockState);
|
||||
if (heat > 0) {
|
||||
activeHeat += heat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(activeHeat!=prevHeat)
|
||||
notifyUpdate();
|
||||
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void setController(BlockPos controller) {
|
||||
if (level.isClientSide && !isVirtual())
|
||||
@@ -344,22 +420,23 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
sendData();
|
||||
}
|
||||
|
||||
private void refreshCapability() {
|
||||
public void refreshCapability() {
|
||||
LazyOptional<IFluidHandler> oldCap = fluidCapability;
|
||||
fluidCapability = LazyOptional.of(() -> handlerForCapability());
|
||||
oldCap.invalidate();
|
||||
}
|
||||
|
||||
private IFluidHandler handlerForCapability() {
|
||||
|
||||
return isController()
|
||||
? tower.isActive()
|
||||
? tower.createHandler()
|
||||
|
||||
: tankInventory
|
||||
: getControllerBE() != null ? getControllerBE().handlerForCapability()
|
||||
: new FluidTank(0);
|
||||
}
|
||||
|
||||
|
||||
private IFluidHandler handlerForCapability() {
|
||||
return isController() ?
|
||||
tankInventory
|
||||
: getControllerBE() != null ? getControllerBE().handlerForCapability() : tankInventory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public BlockPos getController() {
|
||||
@@ -385,12 +462,16 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
@Override
|
||||
public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
|
||||
SteelTankBlockEntity controllerTE = getControllerBE();
|
||||
if (controllerTE == null)
|
||||
|
||||
if(isDistillationTower)
|
||||
return false;
|
||||
if (controllerTE.tower.addToGoggleTooltip(tooltip, isPlayerSneaking, controllerTE.getTotalTankSize()))
|
||||
return true;
|
||||
|
||||
if(getControllerBE()!=null)
|
||||
if(getControllerBE().isDistillationTower)
|
||||
return false;
|
||||
|
||||
return containedFluidTooltip(tooltip, isPlayerSneaking,
|
||||
controllerTE.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY));
|
||||
controllerTE.getCapability(ForgeCapabilities.FLUID_HANDLER));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -406,6 +487,7 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
luminosity = compound.getInt("Luminosity");
|
||||
controller = null;
|
||||
lastKnownPos = null;
|
||||
isDistillationTower = compound.getBoolean("isDistillationTower");
|
||||
|
||||
if (compound.contains("LastKnownPos"))
|
||||
lastKnownPos = NbtUtils.readBlockPos(compound.getCompound("LastKnownPos"));
|
||||
@@ -422,7 +504,7 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
tankInventory.drain(-tankInventory.getSpace(), FluidAction.EXECUTE);
|
||||
}
|
||||
|
||||
tower.read(compound.getCompound("Boiler"), width * width * height);
|
||||
|
||||
|
||||
if (compound.contains("ForceFluidLevel") || fluidLevel == null)
|
||||
fluidLevel = LerpedFloat.linear()
|
||||
@@ -456,16 +538,8 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
fluidLevel.chase(fluidLevel.getChaseTarget(), 0.125f, Chaser.EXP);
|
||||
}
|
||||
public void getGaugeRotation(){
|
||||
int level=tower.towerLevel;
|
||||
|
||||
if(level>=12){
|
||||
gaugeRotation=90;
|
||||
} else
|
||||
if(level>=4){
|
||||
gaugeRotation=45;
|
||||
} else{
|
||||
gaugeRotation=0;
|
||||
}
|
||||
gaugeRotation = Math.min(90,activeHeat*15);
|
||||
|
||||
|
||||
}
|
||||
@@ -478,7 +552,7 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
|
||||
if (updateConnectivity)
|
||||
compound.putBoolean("Uninitialized", true);
|
||||
compound.put("Boiler", tower.write());
|
||||
compound.putBoolean("isDistillationTower",isDistillationTower);
|
||||
if (lastKnownPos != null)
|
||||
compound.put("LastKnownPos", NbtUtils.writeBlockPos(lastKnownPos));
|
||||
if (!isController())
|
||||
@@ -507,7 +581,7 @@ public class SteelTankBlockEntity extends FluidTankBlockEntity implements IHaveG
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
|
||||
if (!fluidCapability.isPresent())
|
||||
refreshCapability();
|
||||
if (cap == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
||||
if (cap == ForgeCapabilities.FLUID_HANDLER)
|
||||
return fluidCapability.cast();
|
||||
return super.getCapability(cap, side);
|
||||
}
|
||||
|
||||
@@ -7,16 +7,16 @@ import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CreosoteBucketItem extends BucketItem {
|
||||
public CreosoteBucketItem(Fluid p_40689_, Properties p_40690_) {
|
||||
public class BadFuelBucketItem extends BucketItem {
|
||||
public BadFuelBucketItem(Fluid p_40689_, Properties p_40690_) {
|
||||
super(p_40689_, p_40690_);
|
||||
}
|
||||
public CreosoteBucketItem(java.util.function.Supplier<? extends Fluid> supplier, Item.Properties builder) {
|
||||
public BadFuelBucketItem(java.util.function.Supplier<? extends Fluid> supplier, Item.Properties builder) {
|
||||
super(supplier,builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBurnTime(ItemStack itemStack, @Nullable RecipeType<?> recipeType) {
|
||||
return 800;
|
||||
return 200;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.drmangotea.createindustry.items;
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.blocks.pipes.normal.LockablePipeBlockEntity;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.simibubi.create.content.fluids.pipes.FluidPipeBlock;
|
||||
@@ -39,9 +40,9 @@ public class ScrewdriverItem extends Item {
|
||||
|
||||
|
||||
if(
|
||||
level.getBlockState(positionClicked).is(TFMGBlocks.STEEL_PIPE.get())||
|
||||
level.getBlockState(positionClicked).is(TFMGBlocks.ALUMINUM_PIPE.get())||
|
||||
level.getBlockState(positionClicked).is(TFMGBlocks.PLASTIC_PIPE.get())
|
||||
level.getBlockState(positionClicked).is(TFMGPipes.STEEL_PIPE.get())||
|
||||
level.getBlockState(positionClicked).is(TFMGPipes.ALUMINUM_PIPE.get())||
|
||||
level.getBlockState(positionClicked).is(TFMGPipes.PLASTIC_PIPE.get())
|
||||
) {
|
||||
//level.playSound(player, positionClicked, SoundEvents.COPPER_STEP, SoundSource.BLOCKS, 0.3f,0.5f);
|
||||
((LockablePipeBlockEntity)level.getBlockEntity(positionClicked)).toggleLock(player);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.items.gadgets.explosives.napalm;
|
||||
package com.drmangotea.createindustry.items.weapons.explosives.napalm;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.drmangotea.createindustry.items.gadgets.explosives.napalm;
|
||||
package com.drmangotea.createindustry.items.weapons.explosives.napalm;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.spark.Spark;
|
||||
import com.drmangotea.createindustry.base.util.TFMGUtils;
|
||||
import com.drmangotea.createindustry.base.util.spark.Spark;
|
||||
import com.drmangotea.createindustry.registry.TFMGEntityTypes;
|
||||
import com.simibubi.create.Create;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
@@ -84,17 +86,19 @@ public class NapalmBombEntity extends Entity {
|
||||
|
||||
protected void explode() {
|
||||
|
||||
float f = 4.0F;
|
||||
for (int i=0; i<40;i++){
|
||||
float x= Create.RANDOM.nextFloat(360);
|
||||
float y= Create.RANDOM.nextFloat(360);
|
||||
float z= Create.RANDOM.nextFloat(360);
|
||||
Spark spark = TFMGEntityTypes.SPARK.create(level);
|
||||
spark.moveTo(this.getX(), this.getY()+1, this.getZ());
|
||||
spark.shootFromRotation( this,x,y,z,0.3f,1);
|
||||
this.level.addFreshEntity(spark);
|
||||
}
|
||||
this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), 2.5F, Explosion.BlockInteraction.BREAK);
|
||||
TFMGUtils.createFireExplosion(level,this,new BlockPos(getX(),getY(),getZ()),40,2.5f);
|
||||
|
||||
// float f = 4.0F;
|
||||
// for (int i=0; i<40;i++){
|
||||
// float x= Create.RANDOM.nextFloat(360);
|
||||
// float y= Create.RANDOM.nextFloat(360);
|
||||
// float z= Create.RANDOM.nextFloat(360);
|
||||
// Spark spark = TFMGEntityTypes.SPARK.create(level);
|
||||
// spark.moveTo(this.getX(), this.getY()+1, this.getZ());
|
||||
// spark.shootFromRotation( this,x,y,z,0.3f,1);
|
||||
// this.level.addFreshEntity(spark);
|
||||
// }
|
||||
// this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), 2.5F, Explosion.BlockInteraction.BREAK);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.items.gadgets.explosives.napalm;
|
||||
package com.drmangotea.createindustry.items.weapons.explosives.napalm;
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.items.gadgets.explosives.thermite_grenades;
|
||||
package com.drmangotea.createindustry.items.weapons.explosives.thermite_grenades;
|
||||
|
||||
public enum ChemicalColor {
|
||||
BASE,
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.drmangotea.createindustry.items.gadgets.explosives.thermite_grenades;
|
||||
package com.drmangotea.createindustry.items.weapons.explosives.thermite_grenades;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.spark.BlueSpark;
|
||||
import com.drmangotea.createindustry.base.spark.GreenSpark;
|
||||
import com.drmangotea.createindustry.base.spark.Spark;
|
||||
import com.drmangotea.createindustry.base.util.spark.BlueSpark;
|
||||
import com.drmangotea.createindustry.base.util.spark.GreenSpark;
|
||||
import com.drmangotea.createindustry.base.util.spark.Spark;
|
||||
import com.drmangotea.createindustry.registry.TFMGEntityTypes;
|
||||
import com.drmangotea.createindustry.registry.TFMGItems;
|
||||
import com.simibubi.create.Create;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.items.gadgets.explosives.thermite_grenades;
|
||||
package com.drmangotea.createindustry.items.weapons.explosives.thermite_grenades;
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGEntityTypes;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.items.gadgets.explosives.thermite_grenades;
|
||||
package com.drmangotea.createindustry.items.weapons.explosives.thermite_grenades;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGItems;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.items.gadgets.explosives.thermite_grenades.fire;
|
||||
package com.drmangotea.createindustry.items.weapons.explosives.thermite_grenades.fire;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.items.gadgets.explosives.thermite_grenades.fire;
|
||||
package com.drmangotea.createindustry.items.weapons.explosives.thermite_grenades.fire;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.items.gadgets.explosives.thermite_grenades.fire;
|
||||
package com.drmangotea.createindustry.items.weapons.explosives.thermite_grenades.fire;
|
||||
|
||||
import com.drmangotea.createindustry.CreateTFMG;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.drmangotea.createindustry.items.gadgets.quad_potato_cannon;
|
||||
package com.drmangotea.createindustry.items.weapons.quad_potato_cannon;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.CreateTFMGClient;
|
||||
import com.drmangotea.createindustry.items.weapons.advanced_potato_cannon.AdvancedPotatoCannonPacket;
|
||||
import com.simibubi.create.AllEnchantments;
|
||||
import com.simibubi.create.AllEntityTypes;
|
||||
import com.simibubi.create.Create;
|
||||
@@ -176,7 +177,7 @@ public class QuadPotatoCannonItem extends ProjectileWeaponItem implements Custom
|
||||
|
||||
ShootableGadgetItemMethods.applyCooldown(player, stack, hand, this::isCannon, cooldown);
|
||||
ShootableGadgetItemMethods.sendPackets(player,
|
||||
b -> new PotatoCannonPacket(barrelPos, lookVec.normalize(), itemStack, hand, soundPitch, b));
|
||||
b -> new AdvancedPotatoCannonPacket(barrelPos, lookVec.normalize(), itemStack, hand, soundPitch, b));
|
||||
|
||||
return InteractionResultHolder.success(stack);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.items.gadgets.quad_potato_cannon;
|
||||
package com.drmangotea.createindustry.items.weapons.quad_potato_cannon;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.CreateTFMGClient;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.drmangotea.createindustry.items.gadgets.quad_potato_cannon;
|
||||
package com.drmangotea.createindustry.items.weapons.quad_potato_cannon;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGItems;
|
||||
@@ -6,7 +6,12 @@ import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.content.equipment.potatoCannon.PotatoProjectileEntity;
|
||||
import com.simibubi.create.content.equipment.zapper.ShootableGadgetRenderHandler;
|
||||
import com.simibubi.create.foundation.particle.AirParticleData;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.core.particles.ItemParticleOption;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
@@ -25,23 +30,23 @@ public class QuadPotatoCannonRenderHandler extends ShootableGadgetRenderHandler
|
||||
return ((QuadPotatoCannonItem) TFMGItems.QUAD_POTATO_CANNON.get())
|
||||
.isCannon(stack);
|
||||
}
|
||||
/*
|
||||
|
||||
public void beforeShoot(float nextPitch, Vec3 location, Vec3 motion, ItemStack stack) {
|
||||
this.nextPitch = nextPitch;
|
||||
if (stack.isEmpty())
|
||||
return;
|
||||
ClientLevel world = Minecraft.getInstance().level;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
Vec3 m = VecHelper.offsetRandomly(motion.scale(0.1f), Create.RANDOM, .025f);
|
||||
Vec3 m = VecHelper.offsetRandomly(motion.scale(0.1f), world.random, .025f);
|
||||
world.addParticle(new ItemParticleOption(ParticleTypes.ITEM, stack), location.x, location.y, location.z, m.x,
|
||||
m.y, m.z);
|
||||
|
||||
Vec3 m2 = VecHelper.offsetRandomly(motion.scale(2f), Create.RANDOM, .5f);
|
||||
Vec3 m2 = VecHelper.offsetRandomly(motion.scale(2f), world.random, .5f);
|
||||
world.addParticle(new AirParticleData(1, 1 / 4f), location.x, location.y, location.z, m2.x, m2.y, m2.z);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@Override
|
||||
protected void transformTool(PoseStack ms, float flip, float equipProgress, float recoil, float pt) {
|
||||
@@ -2,8 +2,10 @@ package com.drmangotea.createindustry.mixins;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.worldgen.TFMGLayeredPatterns;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.data.DynamicDataProvider;
|
||||
import com.simibubi.create.foundation.utility.Couple;
|
||||
import com.simibubi.create.infrastructure.worldgen.AllLayerPatterns;
|
||||
import com.simibubi.create.infrastructure.worldgen.AllOreFeatureConfigEntries;
|
||||
import com.simibubi.create.infrastructure.worldgen.OreFeatureConfigEntry;
|
||||
@@ -30,6 +32,9 @@ import java.util.Map;
|
||||
@Mixin(AllOreFeatureConfigEntries.class)
|
||||
public class AllOreFeatureConfigEntriesMixin {
|
||||
|
||||
|
||||
|
||||
|
||||
@Shadow
|
||||
public static final OreFeatureConfigEntry STRIATED_ORES_OVERWORLD =
|
||||
create("striated_ores_overworld", 32, 1 / 18f, -30, 70)
|
||||
@@ -37,7 +42,7 @@ public class AllOreFeatureConfigEntriesMixin {
|
||||
.withLayerPattern(TFMGLayeredPatterns.BAUXITE)
|
||||
.withLayerPattern(TFMGLayeredPatterns.LIGNITE)
|
||||
.withLayerPattern(TFMGLayeredPatterns.FIRECLAY)
|
||||
//.withLayerPattern(TFMGLayeredPatterns.GALENA)
|
||||
.withLayerPattern(TFMGLayeredPatterns.GALENA)
|
||||
.withLayerPattern(AllLayerPatterns.SCORIA)
|
||||
.withLayerPattern(AllLayerPatterns.CINNABAR)
|
||||
.withLayerPattern(AllLayerPatterns.MAGNETITE)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.drmangotea.createindustry.mixins;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGPipes;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllTags;
|
||||
@@ -48,6 +49,10 @@ public class FluidPropagatorMixin {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author DrMangoTea
|
||||
* @reason felt like it
|
||||
*/
|
||||
@Overwrite( remap = false)
|
||||
public static void propagateChangedPipe(LevelAccessor world, BlockPos pipePos, BlockState pipeState) {
|
||||
List<Pair<Integer, BlockPos>> frontier = new ArrayList<>();
|
||||
@@ -80,12 +85,12 @@ public class FluidPropagatorMixin {
|
||||
BlockState targetState = world.getBlockState(target);
|
||||
if (tileEntity instanceof PumpBlockEntity) {
|
||||
if (
|
||||
!TFMGBlocks.STEEL_MECHANICAL_PUMP.has(targetState)&&
|
||||
!TFMGPipes.STEEL_MECHANICAL_PUMP.has(targetState)&&
|
||||
!AllBlocks.MECHANICAL_PUMP.has(targetState)&&
|
||||
!TFMGBlocks.BRASS_MECHANICAL_PUMP.has(targetState)&&
|
||||
!TFMGBlocks.CAST_IRON_MECHANICAL_PUMP.has(targetState)&&
|
||||
!TFMGBlocks.ALUMINUM_MECHANICAL_PUMP.has(targetState)&&
|
||||
!TFMGBlocks.PLASTIC_MECHANICAL_PUMP.has(targetState)
|
||||
!TFMGPipes.BRASS_MECHANICAL_PUMP.has(targetState)&&
|
||||
!TFMGPipes.CAST_IRON_MECHANICAL_PUMP.has(targetState)&&
|
||||
!TFMGPipes.ALUMINUM_MECHANICAL_PUMP.has(targetState)&&
|
||||
!TFMGPipes.PLASTIC_MECHANICAL_PUMP.has(targetState)
|
||||
|| targetState.getValue(PumpBlock.FACING)
|
||||
.getAxis() != direction.getAxis())
|
||||
continue;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.drmangotea.createindustry.ponder;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.CreateTFMG;
|
||||
import com.drmangotea.createindustry.ponder.scenes.ElectricityScenes;
|
||||
import com.drmangotea.createindustry.ponder.scenes.MetallurgyScenes;
|
||||
import com.drmangotea.createindustry.ponder.scenes.OilScenes;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
@@ -24,7 +25,11 @@ public class TFMGPonderIndex {
|
||||
.addStoryBoard("radial_engines", OilScenes::radial_engines, TFMGPonderTag.OIL);
|
||||
|
||||
|
||||
HELPER.forComponents(TFMGBlocks.DIESEL_ENGINE)
|
||||
HELPER.forComponents(
|
||||
TFMGBlocks.DIESEL_ENGINE,
|
||||
TFMGBlocks.AIR_INTAKE,
|
||||
TFMGBlocks.DIESEL_ENGINE_EXPANSION
|
||||
)
|
||||
|
||||
.addStoryBoard("diesel_engine", OilScenes::diesel_engine, TFMGPonderTag.OIL)
|
||||
.addStoryBoard("diesel_engine_expansion", OilScenes::diesel_engine_expansion, TFMGPonderTag.OIL);
|
||||
@@ -63,6 +68,11 @@ public class TFMGPonderIndex {
|
||||
HELPER.forComponents(TFMGBlocks.CASTING_BASIN,TFMGBlocks.CASTING_SPOUT)
|
||||
|
||||
.addStoryBoard("casting", MetallurgyScenes::casting, TFMGPonderTag.METALLURGY);
|
||||
/////////////////////////////////////////
|
||||
|
||||
HELPER.forComponents(TFMGBlocks.ROTOR,TFMGBlocks.STATOR)
|
||||
|
||||
.addStoryBoard("large_generator", ElectricityScenes::large_generator, TFMGPonderTag.ELECTRICITY);
|
||||
|
||||
|
||||
}
|
||||
@@ -94,6 +104,13 @@ public class TFMGPonderIndex {
|
||||
.add(TFMGBlocks.FIREPROOF_BRICK_REINFORCEMENT)
|
||||
.add(TFMGBlocks.BLAST_FURNACE_OUTPUT);
|
||||
|
||||
PonderRegistry.TAGS.forTag(TFMGPonderTag.ELECTRICITY)
|
||||
.add(TFMGBlocks.STATOR)
|
||||
.add(TFMGBlocks.ROTOR)
|
||||
.add(TFMGBlocks.CABLE_CONNECTOR)
|
||||
.add(TFMGBlocks.CAPACITOR)
|
||||
.add(TFMGBlocks.ACCUMULATOR);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ public class TFMGPonderTag extends PonderTag {
|
||||
.defaultLang("Metal processing", "Machines related to metal")
|
||||
.item(TFMGItems.STEEL_INGOT.get(), true, false).addToIndex();
|
||||
|
||||
public static final PonderTag ELECTRICITY = create("electricity")
|
||||
.defaultLang("Electric Machinery", "")
|
||||
.item(TFMGItems.STEEL_INGOT.get(), true, false).addToIndex();
|
||||
|
||||
public TFMGPonderTag(ResourceLocation id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ public class CastingRecipe extends ProcessingRecipe<RecipeWrapper> {
|
||||
protected int getMaxOutputCount() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMaxFluidOutputCount() {
|
||||
protected int getMaxFluidInputCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
public boolean matches(CombinedTankWrapper inv, Level worldIn) {
|
||||
if (inv.getFluidInTank(0).getAmount()==0)
|
||||
return false;
|
||||
|
||||
@@ -1,264 +0,0 @@
|
||||
package com.drmangotea.createindustry.recipes.distillation;
|
||||
|
||||
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillation_tower.DistillationControllerBlockEntity;
|
||||
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillery.DistilleryControllerBlockEntity;
|
||||
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock;
|
||||
import com.simibubi.create.content.processing.recipe.ProcessingRecipe;
|
||||
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.fluid.SmartFluidTankBehaviour;
|
||||
import com.simibubi.create.foundation.fluid.FluidIngredient;
|
||||
import com.simibubi.create.foundation.item.SmartInventory;
|
||||
import com.simibubi.create.foundation.recipe.IRecipeTypeInfo;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@SuppressWarnings("removal")
|
||||
public class AbstractDistillationRecipe extends ProcessingRecipe<SmartInventory> {
|
||||
|
||||
public static boolean match(DistilleryControllerBlockEntity controller, Recipe<?> recipe) {
|
||||
|
||||
|
||||
|
||||
|
||||
if(recipe instanceof AbstractDistillationRecipe) {
|
||||
return apply(controller, recipe, true);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static boolean apply(DistilleryControllerBlockEntity controller, Recipe<?> recipe) {
|
||||
return apply(controller, recipe, false);
|
||||
}
|
||||
|
||||
private static boolean apply(DistilleryControllerBlockEntity controller, Recipe<?> recipe, boolean test) {
|
||||
boolean isItemlessRecipe = recipe instanceof AbstractDistillationRecipe;
|
||||
IItemHandler availableItems = controller.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
.orElse(null);
|
||||
IFluidHandler availableFluids = controller.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
||||
.orElse(null);
|
||||
|
||||
if (availableItems == null || availableFluids == null)
|
||||
return false;
|
||||
|
||||
BlazeBurnerBlock.HeatLevel heat = DistilleryControllerBlockEntity.getHeatLevelOf(controller.getLevel()
|
||||
.getBlockState(controller.getBlockPos()
|
||||
.below(1)));
|
||||
if (isItemlessRecipe && !((AbstractDistillationRecipe) recipe).getRequiredHeat()
|
||||
.testBlazeBurner(heat))
|
||||
return false;
|
||||
|
||||
List<ItemStack> recipeOutputItems = new ArrayList<>();
|
||||
List<FluidStack> recipeOutputFluids = new ArrayList<>();
|
||||
|
||||
|
||||
List<FluidIngredient> fluidIngredients =
|
||||
isItemlessRecipe ? ((AbstractDistillationRecipe) recipe).getFluidIngredients() : Collections.emptyList();
|
||||
if(!fluidIngredients.isEmpty())
|
||||
|
||||
|
||||
|
||||
|
||||
for (boolean simulate : Iterate.trueAndFalse) {
|
||||
|
||||
if (!simulate && test)
|
||||
return true;
|
||||
|
||||
int[] extractedFluidsFromTank = new int[availableFluids.getTanks()];
|
||||
|
||||
|
||||
boolean fluidsAffected = false;
|
||||
FluidIngredients: for (int i = 0; i < fluidIngredients.size(); i++) {
|
||||
FluidIngredient fluidIngredient = fluidIngredients.get(i);
|
||||
int amountRequired = fluidIngredient.getRequiredAmount();
|
||||
|
||||
|
||||
for (int tank = 0; tank < availableFluids.getTanks(); tank++) {
|
||||
FluidStack fluidStack = availableFluids.getFluidInTank(tank);
|
||||
if (simulate && fluidStack.getAmount() <= extractedFluidsFromTank[tank])
|
||||
continue;
|
||||
if (!fluidIngredient.test(fluidStack))
|
||||
continue;
|
||||
int drainedAmount = Math.min(amountRequired, fluidStack.getAmount());
|
||||
if (!simulate) {
|
||||
fluidStack.shrink(drainedAmount);
|
||||
fluidsAffected = true;
|
||||
}
|
||||
amountRequired -= drainedAmount;
|
||||
if (amountRequired != 0)
|
||||
continue;
|
||||
extractedFluidsFromTank[tank] += drainedAmount;
|
||||
continue FluidIngredients;
|
||||
}
|
||||
|
||||
// something wasn't found
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fluidsAffected) {
|
||||
controller.getBehaviour(SmartFluidTankBehaviour.INPUT)
|
||||
.forEach(SmartFluidTankBehaviour.TankSegment::onFluidStackChanged);
|
||||
controller.getBehaviour(SmartFluidTankBehaviour.OUTPUT)
|
||||
.forEach(SmartFluidTankBehaviour.TankSegment::onFluidStackChanged);
|
||||
}
|
||||
|
||||
if (simulate) {
|
||||
if (recipe instanceof AbstractDistillationRecipe ItemlessRecipe) {
|
||||
recipeOutputItems.addAll(ItemlessRecipe.rollResults());
|
||||
recipeOutputFluids.addAll(ItemlessRecipe.getFluidResults());
|
||||
|
||||
} else {
|
||||
recipeOutputItems.add(recipe.getResultItem());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
public static boolean match2(DistillationControllerBlockEntity controller, Recipe<?> recipe) {
|
||||
|
||||
|
||||
if(recipe instanceof AbstractDistillationRecipe) {
|
||||
return apply(controller, recipe, true);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
private static boolean apply2(DistillationControllerBlockEntity controller, Recipe<?> recipe, boolean test) {
|
||||
boolean isItemlessRecipe = recipe instanceof AbstractDistillationRecipe;
|
||||
IItemHandler availableItems = controller.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
.orElse(null);
|
||||
IFluidHandler availableFluids = controller.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
||||
.orElse(null);
|
||||
|
||||
if (availableItems == null || availableFluids == null)
|
||||
return false;
|
||||
|
||||
BlazeBurnerBlock.HeatLevel heat = DistilleryControllerBlockEntity.getHeatLevelOf(controller.getLevel()
|
||||
.getBlockState(controller.getBlockPos()
|
||||
.below(1)));
|
||||
if (isItemlessRecipe && !((AbstractDistillationRecipe) recipe).getRequiredHeat()
|
||||
.testBlazeBurner(heat))
|
||||
return false;
|
||||
|
||||
List<ItemStack> recipeOutputItems = new ArrayList<>();
|
||||
List<FluidStack> recipeOutputFluids = new ArrayList<>();
|
||||
|
||||
|
||||
List<FluidIngredient> fluidIngredients =
|
||||
isItemlessRecipe ? ((AbstractDistillationRecipe) recipe).getFluidIngredients() : Collections.emptyList();
|
||||
if(!fluidIngredients.isEmpty())
|
||||
|
||||
|
||||
|
||||
|
||||
for (boolean simulate : Iterate.trueAndFalse) {
|
||||
|
||||
if (!simulate && test)
|
||||
return true;
|
||||
|
||||
int[] extractedFluidsFromTank = new int[availableFluids.getTanks()];
|
||||
|
||||
|
||||
boolean fluidsAffected = false;
|
||||
FluidIngredients: for (int i = 0; i < fluidIngredients.size(); i++) {
|
||||
FluidIngredient fluidIngredient = fluidIngredients.get(i);
|
||||
int amountRequired = fluidIngredient.getRequiredAmount();
|
||||
|
||||
|
||||
for (int tank = 0; tank < availableFluids.getTanks(); tank++) {
|
||||
FluidStack fluidStack = availableFluids.getFluidInTank(tank);
|
||||
if (simulate && fluidStack.getAmount() <= extractedFluidsFromTank[tank])
|
||||
continue;
|
||||
if (!fluidIngredient.test(fluidStack))
|
||||
continue;
|
||||
int drainedAmount = Math.min(amountRequired, fluidStack.getAmount());
|
||||
if (!simulate) {
|
||||
fluidStack.shrink(drainedAmount);
|
||||
fluidsAffected = true;
|
||||
}
|
||||
amountRequired -= drainedAmount;
|
||||
if (amountRequired != 0)
|
||||
continue;
|
||||
extractedFluidsFromTank[tank] += drainedAmount;
|
||||
continue FluidIngredients;
|
||||
}
|
||||
|
||||
// something wasn't found
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fluidsAffected) {
|
||||
controller.getBehaviour(SmartFluidTankBehaviour.INPUT)
|
||||
.forEach(SmartFluidTankBehaviour.TankSegment::onFluidStackChanged);
|
||||
controller.getBehaviour(SmartFluidTankBehaviour.OUTPUT)
|
||||
.forEach(SmartFluidTankBehaviour.TankSegment::onFluidStackChanged);
|
||||
}
|
||||
|
||||
if (simulate) {
|
||||
if (recipe instanceof AbstractDistillationRecipe ItemlessRecipe) {
|
||||
recipeOutputItems.addAll(ItemlessRecipe.rollResults());
|
||||
recipeOutputFluids.addAll(ItemlessRecipe.getFluidResults());
|
||||
|
||||
} else {
|
||||
recipeOutputItems.add(recipe.getResultItem());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected AbstractDistillationRecipe(IRecipeTypeInfo type, ProcessingRecipeBuilder.ProcessingRecipeParams params) {
|
||||
super(type, params);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getMaxInputCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMaxOutputCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMaxFluidInputCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMaxFluidOutputCount() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canRequireHeat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(SmartInventory inv, @Nonnull Level worldIn) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package com.drmangotea.createindustry.recipes.distillation;
|
||||
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGRecipeTypes;
|
||||
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder;
|
||||
import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
|
||||
import com.simibubi.create.foundation.fluid.FluidIngredient;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class AdvancedDistillationRecipe extends AbstractDistillationRecipe {
|
||||
|
||||
public AdvancedDistillationRecipe(ProcessingRecipeBuilder.ProcessingRecipeParams params) {
|
||||
super(TFMGRecipeTypes.ADVANCED_DISTILLATION, params);
|
||||
}
|
||||
|
||||
public FluidIngredient getInputFluid(){
|
||||
return getFluidIngredients().get(0);
|
||||
}
|
||||
|
||||
public FluidStack getFirstFluidResult(){
|
||||
return fluidResults.get(0);
|
||||
}
|
||||
public FluidStack getSecondFluidResult(){
|
||||
return fluidResults.get(1);
|
||||
}
|
||||
public FluidStack getThirdFluidResult(){
|
||||
return fluidResults.get(2);
|
||||
}
|
||||
public FluidStack getFourthFluidResult(){
|
||||
return fluidResults.get(3);
|
||||
}
|
||||
public FluidStack getFifthFluidResult(){
|
||||
return fluidResults.get(4);
|
||||
}
|
||||
public FluidStack getSixthFluidResult(){
|
||||
return fluidResults.get(5);
|
||||
}
|
||||
|
||||
|
||||
public int getOutputCount(AdvancedDistillationRecipe recipe){
|
||||
return recipe.fluidResults.toArray().length;
|
||||
}
|
||||
public NonNullList<FluidStack> getResults(){
|
||||
return fluidResults;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getMaxFluidOutputCount() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMaxOutputCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean matches(CombinedTankWrapper inv) {
|
||||
if (inv.getFluidInTank(0).getAmount()==0)
|
||||
return false;
|
||||
return fluidIngredients.get(0)
|
||||
.test(inv.getFluidInTank(0));
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,21 @@ package com.drmangotea.createindustry.recipes.distillation;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGRecipeTypes;
|
||||
import com.simibubi.create.content.processing.recipe.ProcessingRecipe;
|
||||
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder;
|
||||
import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
|
||||
import com.simibubi.create.foundation.fluid.FluidIngredient;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import com.simibubi.create.foundation.item.SmartInventory;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
|
||||
public class DistillationRecipe extends ProcessingRecipe<SmartInventory> {
|
||||
|
||||
|
||||
|
||||
|
||||
public class DistillationRecipe extends AbstractDistillationRecipe {
|
||||
|
||||
public DistillationRecipe(ProcessingRecipeBuilder.ProcessingRecipeParams params) {
|
||||
super(TFMGRecipeTypes.DISTILLATION, params);
|
||||
@@ -27,14 +36,69 @@ public class DistillationRecipe extends AbstractDistillationRecipe {
|
||||
public FluidStack getThirdFluidResult(){
|
||||
return fluidResults.get(2);
|
||||
}
|
||||
public FluidStack getFourthFluidResult(){
|
||||
return fluidResults.get(3);
|
||||
}
|
||||
public FluidStack getFifthFluidResult(){
|
||||
return fluidResults.get(4);
|
||||
}
|
||||
public FluidStack getSixthFluidResult(){
|
||||
return fluidResults.get(5);
|
||||
}
|
||||
|
||||
public ItemStack getFirstItemResult(){
|
||||
return results.get(0).getStack();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public int getOutputCount(DistillationRecipe recipe){
|
||||
return recipe.fluidResults.toArray().length;
|
||||
}
|
||||
public ItemStack getSecondItemResult(){
|
||||
return results.get(1).getStack();
|
||||
public NonNullList<FluidStack> getResults(){
|
||||
return fluidResults;
|
||||
}
|
||||
public ItemStack getThirdItemResult(){
|
||||
return results.get(2).getStack();
|
||||
|
||||
|
||||
@Override
|
||||
protected int getMaxFluidOutputCount() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMaxInputCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMaxFluidInputCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMaxOutputCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean matches(FluidTank inv,int outputs) {
|
||||
|
||||
int neededOutputs = fluidIngredients.toArray().length;
|
||||
|
||||
if(outputs !=neededOutputs)
|
||||
return false;
|
||||
|
||||
if (inv.getFluidInTank(0).getAmount()==0)
|
||||
return false;
|
||||
return fluidIngredients.get(0)
|
||||
.test(inv.getFluidInTank(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(SmartInventory pContainer, Level pLevel) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ package com.drmangotea.createindustry.recipes.jei;
|
||||
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.recipes.distillation.AdvancedDistillationRecipe;
|
||||
import com.drmangotea.createindustry.recipes.jei.machines.Distillery;
|
||||
import com.drmangotea.createindustry.recipes.distillation.DistillationRecipe;
|
||||
import com.drmangotea.createindustry.registry.TFMGGuiTextures;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.compat.jei.category.CreateRecipeCategory;
|
||||
@@ -19,11 +18,11 @@ import mezz.jei.api.recipe.RecipeIngredientRole;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public class AdvancedDistillationCategory extends CreateRecipeCategory<AdvancedDistillationRecipe> {
|
||||
public class AdvancedDistillationCategory extends CreateRecipeCategory<DistillationRecipe> {
|
||||
|
||||
|
||||
|
||||
public AdvancedDistillationCategory(Info<AdvancedDistillationRecipe> info) {
|
||||
public AdvancedDistillationCategory(Info<DistillationRecipe> info) {
|
||||
super(info);
|
||||
}
|
||||
|
||||
@@ -31,7 +30,7 @@ public class AdvancedDistillationCategory extends CreateRecipeCategory<AdvancedD
|
||||
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayoutBuilder builder, AdvancedDistillationRecipe recipe, IFocusGroup focuses) {
|
||||
public void setRecipe(IRecipeLayoutBuilder builder, DistillationRecipe recipe, IFocusGroup focuses) {
|
||||
FluidIngredient fluidIngredient=recipe.getInputFluid();
|
||||
|
||||
int outputCount = recipe.getOutputCount(recipe);
|
||||
@@ -58,7 +57,7 @@ public class AdvancedDistillationCategory extends CreateRecipeCategory<AdvancedD
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(AdvancedDistillationRecipe recipe, IRecipeSlotsView iRecipeSlotsView, PoseStack matrixStack, double mouseX, double mouseY) {
|
||||
public void draw(DistillationRecipe recipe, IRecipeSlotsView iRecipeSlotsView, PoseStack matrixStack, double mouseX, double mouseY) {
|
||||
int outputCount = recipe.getOutputCount(recipe);
|
||||
int yModifier = 60 -(outputCount*10);
|
||||
int y = 126-yModifier;
|
||||
|
||||
@@ -4,7 +4,6 @@ package com.drmangotea.createindustry.recipes.jei;
|
||||
|
||||
import com.drmangotea.createindustry.recipes.coking.CokingRecipe;
|
||||
import com.drmangotea.createindustry.recipes.jei.machines.CokeOven;
|
||||
import com.drmangotea.createindustry.recipes.jei.machines.Distillery;
|
||||
import com.drmangotea.createindustry.registry.TFMGFluids;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.compat.jei.category.CreateRecipeCategory;
|
||||
@@ -14,7 +13,6 @@ import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
|
||||
import mezz.jei.api.recipe.IFocusGroup;
|
||||
import mezz.jei.api.recipe.RecipeIngredientRole;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
package com.drmangotea.createindustry.recipes.jei;
|
||||
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.recipes.distillation.DistillationRecipe;
|
||||
import com.drmangotea.createindustry.recipes.jei.machines.Distillery;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.compat.jei.category.CreateRecipeCategory;
|
||||
import com.simibubi.create.foundation.fluid.FluidIngredient;
|
||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||
import mezz.jei.api.forge.ForgeTypes;
|
||||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
|
||||
import mezz.jei.api.recipe.IFocusGroup;
|
||||
import mezz.jei.api.recipe.RecipeIngredientRole;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public class DistillationCategory extends CreateRecipeCategory<DistillationRecipe> {
|
||||
|
||||
private final Distillery distiller = new Distillery();
|
||||
|
||||
public DistillationCategory(Info<DistillationRecipe> info) {
|
||||
super(info);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayoutBuilder builder, DistillationRecipe recipe, IFocusGroup focuses) {
|
||||
ItemStack result1 = recipe.getFirstItemResult();
|
||||
ItemStack result2 = recipe.getSecondItemResult();
|
||||
FluidIngredient fluidIngredient=recipe.getInputFluid();
|
||||
|
||||
|
||||
builder
|
||||
.addSlot(RecipeIngredientRole.INPUT, 2, 75)
|
||||
.setBackground(getRenderedSlot(), -1, -1)
|
||||
.addIngredients(ForgeTypes.FLUID_STACK, withImprovedVisibility(recipe.getInputFluid().getMatchingFluidStacks()))
|
||||
.addTooltipCallback(addFluidTooltip(recipe.getInputFluid().getRequiredAmount()));
|
||||
|
||||
|
||||
|
||||
builder
|
||||
.addSlot(RecipeIngredientRole.OUTPUT,150, 55)
|
||||
.setBackground(getRenderedSlot(), -1, -1)
|
||||
.addIngredient(ForgeTypes.FLUID_STACK, withImprovedVisibility(recipe.getFirstFluidResult()))
|
||||
.addTooltipCallback(addFluidTooltip(recipe.getFirstFluidResult().getAmount()));
|
||||
builder
|
||||
.addSlot(RecipeIngredientRole.OUTPUT,150, 33)
|
||||
.setBackground(getRenderedSlot(), -1, -1)
|
||||
.addIngredient(ForgeTypes.FLUID_STACK, withImprovedVisibility(recipe.getSecondFluidResult()))
|
||||
.addTooltipCallback(addFluidTooltip(recipe.getSecondFluidResult().getAmount()));
|
||||
|
||||
builder
|
||||
.addSlot(RecipeIngredientRole.OUTPUT,150, 12)
|
||||
.setBackground(getRenderedSlot(), -1, -1)
|
||||
.addIngredient(ForgeTypes.FLUID_STACK, withImprovedVisibility(recipe.getThirdFluidResult()))
|
||||
.addTooltipCallback(addFluidTooltip(recipe.getThirdFluidResult().getAmount()));
|
||||
|
||||
|
||||
|
||||
builder
|
||||
.addSlot(RecipeIngredientRole.OUTPUT, 105, 100)
|
||||
.setBackground(getRenderedSlot(), -1, -1)
|
||||
.addItemStack(recipe.getFirstItemResult());
|
||||
builder
|
||||
.addSlot(RecipeIngredientRole.OUTPUT, 127, 100)
|
||||
.setBackground(getRenderedSlot(), -1, -1)
|
||||
.addItemStack(recipe.getSecondItemResult());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(DistillationRecipe recipe, IRecipeSlotsView iRecipeSlotsView, PoseStack matrixStack, double mouseX, double mouseY) {
|
||||
distiller
|
||||
.draw(matrixStack, 65, 27);
|
||||
AllGuiTextures.JEI_ARROW.render(matrixStack, 20, 80);
|
||||
AllGuiTextures.JEI_ARROW.render(matrixStack, 100, 14);
|
||||
AllGuiTextures.JEI_ARROW.render(matrixStack, 100, 35);
|
||||
AllGuiTextures.JEI_ARROW.render(matrixStack, 100, 57);
|
||||
AllGuiTextures.JEI_DOWN_ARROW.render(matrixStack, 100, 79);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,6 @@ package com.drmangotea.createindustry.recipes.jei;
|
||||
import com.drmangotea.createindustry.recipes.casting.CastingRecipe;
|
||||
import com.drmangotea.createindustry.recipes.coking.CokingRecipe;
|
||||
import com.drmangotea.createindustry.recipes.distillation.DistillationRecipe;
|
||||
import com.drmangotea.createindustry.recipes.distillation.AdvancedDistillationRecipe;
|
||||
import com.drmangotea.createindustry.recipes.industrial_blasting.IndustrialBlastingRecipe;
|
||||
import com.drmangotea.createindustry.registry.TFMGBlocks;
|
||||
import com.drmangotea.createindustry.registry.TFMGFluids;
|
||||
@@ -59,16 +58,10 @@ public class TFMGJei implements IModPlugin {
|
||||
|
||||
CreateRecipeCategory<?>
|
||||
|
||||
distillation = builder(DistillationRecipe.class)
|
||||
.addTypedRecipes(TFMGRecipeTypes.DISTILLATION)
|
||||
.catalyst(TFMGBlocks.CAST_IRON_DISTILLATION_CONTROLLER::get)
|
||||
.itemIcon(TFMGFluids.CRUDE_OIL.getBucket().get())
|
||||
.emptyBackground(177, 123)
|
||||
.build("distillation", DistillationCategory::new)
|
||||
,
|
||||
|
||||
advancedDistillation = builder(AdvancedDistillationRecipe.class)
|
||||
.addTypedRecipes(TFMGRecipeTypes.ADVANCED_DISTILLATION)
|
||||
|
||||
advancedDistillation = builder(DistillationRecipe.class)
|
||||
.addTypedRecipes(TFMGRecipeTypes.DISTILLATION)
|
||||
.catalyst(TFMGBlocks.STEEL_DISTILLATION_CONTROLLER::get)
|
||||
.catalyst(TFMGBlocks.STEEL_DISTILLATION_OUTPUT::get)
|
||||
.itemIcon(TFMGBlocks.STEEL_DISTILLATION_CONTROLLER.get())
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user