Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
updated antimatter mostly finished mining pipe placement in oil drill…
Browse files Browse the repository at this point in the history
…ing rig
  • Loading branch information
Trinsdar committed Aug 4, 2023
1 parent 671c5d1 commit 938fd0c
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 23 deletions.
46 changes: 46 additions & 0 deletions common/src/main/java/muramasa/gregtech/block/BlockMiningPipe.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package muramasa.gregtech.block;

import muramasa.antimatter.block.BlockBasic;
import muramasa.antimatter.datagen.providers.AntimatterBlockStateProvider;
import muramasa.antimatter.registration.IItemBlockProvider;
import muramasa.gregtech.GTIRef;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
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.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;

public class BlockMiningPipe extends BlockBasic implements IItemBlockProvider {
VoxelShape shape = null;
public BlockMiningPipe(String domain, String id, Properties properties) {
super(domain, id, properties);
if (id.equals("mining_pipe_thin")){
shape = Shapes.create(0.375, 0.0, 0.375, 0.625, 1.0, 0.625);
}
}

@Override
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
if (this.id.equals("mining_pipe_thin")){
return shape;
}
return super.getShape(state, level, pos, context);
}

@Override
public void onBlockModelBuild(Block block, AntimatterBlockStateProvider prov) {
if (getId().equals("mining_pipe_thin")){
prov.state(block, prov.getBuilder(block).parent(new ResourceLocation("block/fence_post")).texture("texture", new ResourceLocation(GTIRef.ID, "block/casing/brick")));
return;
}
super.onBlockModelBuild(block, prov);
}

@Override
public boolean generateItemBlock() {
return !getId().equals("mining_pipe");
}
}
4 changes: 2 additions & 2 deletions common/src/main/java/muramasa/gregtech/data/GregTechData.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
Expand Down Expand Up @@ -298,7 +297,8 @@ public Texture[] getTextures() {
}
};

public static final BlockBasic MINING_PIPE = new BlockBasic(GTIRef.ID, "mining_pipe", BlockBehaviour.Properties.of(net.minecraft.world.level.material.Material.STONE, MaterialColor.COLOR_GRAY));
public static final BlockBasic MINING_PIPE_THIN = new BlockMiningPipe(GTIRef.ID, "mining_pipe_thin", BlockBehaviour.Properties.of(net.minecraft.world.level.material.Material.STONE, MaterialColor.COLOR_GRAY));
public static final BlockBasic MINING_PIPE = new BlockMiningPipe(GTIRef.ID, "mining_pipe", BlockBehaviour.Properties.of(net.minecraft.world.level.material.Material.STONE, MaterialColor.COLOR_GRAY));
public static final BlockCasing CASING_ULV = new BlockCasing(GTIRef.ID, "casing_ulv");
public static final BlockCasing CASING_LV = new BlockCasing(GTIRef.ID, "casing_lv");
public static final BlockCasing CASING_MV = new BlockCasing(GTIRef.ID, "casing_mv");
Expand Down
4 changes: 2 additions & 2 deletions common/src/main/java/muramasa/gregtech/data/Machines.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ public class Machines {
public static MultiMachine HEAT_EXCHANGER = new MultiMachine(GTIRef.ID, "heat_exchanger").setTiers(EV).setMap(HEAT_EXCHANGING).addFlags(GUI, FLUID, ENERGY).setTile(TileEntityHeatExchanger::new).custom();
public static MultiMachine IMPLOSION_COMPRESSOR = new MultiMachine(GTIRef.ID, "implosion_compressor").setTiers(HV).setMap(IMPLOSION_COMPRESSING).addFlags(GUI, ITEM, ENERGY).setTile(TileEntityImplosionCompressor::new);
public static MultiMachine LARGE_BOILER = new MultiMachine(GTIRef.ID, "large_boiler").setTiers(LV, MV, HV, EV).addFlags(GUI, ITEM, FLUID).setMap(LARGE_BOILERS).setTile(TileEntityLargeBoiler::new).custom();
public static MultiMachine LARGE_TURBINE = new MultiMachine(GTIRef.ID, "large_turbine").setTiers(HV, EV, IV, UV).setMap(STEAM_FUELS, HV).setMap(HP_STEAM_FUELS, IV).setMap(GAS_FUELS, EV, UV).addFlags(GUI, FLUID, ENERGY, GENERATOR).setTile(TileEntityLargeTurbine::new).custom(Textures.TURBINE);
public static MultiMachine LARGE_TURBINE = new MultiMachine(GTIRef.ID, "large_turbine").setTiers(HV, EV, IV).setMap(STEAM_FUELS, HV).setMap(HP_STEAM_FUELS, IV).setMap(GAS_FUELS, EV).addFlags(GUI, ITEM, FLUID, ENERGY, GENERATOR).setTile(TileEntityLargeTurbine::new).custom(Textures.TURBINE);
public static MultiMachine MULTI_SMELTER = new MultiMachine(GTIRef.ID, "multi_smelter").setTiers(HV).setMap(SMELTING).addFlags(GUI, ITEM, ENERGY).setTile(TileEntityMultiSmelter::new).custom();
public static MultiMachine NUCLEAR_REACTOR = new MultiMachine(GTIRef.ID, "nuclear_reactor").setTiers(EV).setMap(NUCLEAR).addFlags(GUI, ITEM, FLUID, ENERGY).setTile(TileEntityNuclearReactor::new).custom();
public static MultiMachine OIL_DRILLING_RIG = new MultiMachine(GTIRef.ID, "oil_drilling_rig").setTiers(MV).addFlags(GUI, FLUID, ENERGY).setTile(TileEntityOilDrillingRig::new).custom();
public static MultiMachine OIL_DRILLING_RIG = new MultiMachine(GTIRef.ID, "oil_drilling_rig").setTiers(MV).addFlags(GUI, ITEM, FLUID, ENERGY).setTile(TileEntityOilDrillingRig::new).custom();
public static MultiMachine PYROLYSIS_OVEN = new MultiMachine(GTIRef.ID, "pyrolysis_oven").setTiers(MV).setMap(PYROLYSISING).addFlags(GUI, ITEM, FLUID, ENERGY).setTile(TileEntityPyrolysisOven::new).custom();
public static MultiMachine VACUUM_FREEZER = new MultiMachine(GTIRef.ID, "vacuum_freezer").setTiers(HV).setMap(VACUUM_FREEZING).addFlags(GUI, ITEM, FLUID, ENERGY).setTile(TileEntityVacuumFreezer::new);
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package muramasa.gregtech.tile.multi;

import muramasa.antimatter.gui.SlotType;
import muramasa.antimatter.machine.MachineState;
import muramasa.antimatter.machine.types.Machine;
import muramasa.antimatter.material.Material;
import muramasa.antimatter.tile.multi.TileEntityMultiMachine;
import muramasa.antimatter.util.int3;
import muramasa.gregtech.data.GregTechData;
import muramasa.gregtech.data.Materials;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
Expand All @@ -18,44 +18,57 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.material.FluidState;

import javax.annotation.Nullable;

import static muramasa.antimatter.machine.Tier.*;
import static muramasa.gregtech.data.GregTechData.MINING_PIPE;
import static muramasa.gregtech.data.GregTechData.MINING_PIPE_THIN;

public class TileEntityOilDrillingRig extends TileEntityMultiMachine<TileEntityOilDrillingRig> {
boolean foundBottom = false;
boolean erroring = false;
BlockPos.MutableBlockPos miningPos = this.getBlockPos().mutable();
boolean stopped = false;
BlockPos.MutableBlockPos miningPos;

public TileEntityOilDrillingRig(Machine<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
miningPos = new int3(pos, this.getFacing(state)).back(1);
}

@Override
public void serverTick(Level level, BlockPos pos, BlockState state) {
super.serverTick(level, pos, state);
if (erroring || !validStructure) return;
if (!validStructure) return;
ItemStack stack = itemHandler.map(i -> i.getHandler(SlotType.STORAGE).getStackInSlot(0)).orElse(ItemStack.EMPTY);
if (stack.getItem() == GregTechData.MINING_PIPE.asItem() || foundBottom){
if (stack.getItem() == GregTechData.MINING_PIPE_THIN.asItem() || foundBottom){
if (!foundBottom){
miningPos.below();

if (getMachineState() != MachineState.ACTIVE) setMachineState(MachineState.ACTIVE);
if (level.getGameTime() % 40 != 0) return;
if (!stopped) miningPos.below();

BlockState block = level.getBlockState(miningPos);

if (block.isAir()) return;
if (!destroyBlock(level, pos, true, null, Items.DIAMOND.getDefaultInstance())){
erroring = true;
} else {
level.setBlock(miningPos, GregTechData.MINING_PIPE.defaultBlockState(), 0);
if (block.getBlock() == Blocks.BEDROCK || block.getBlock() == Blocks.VOID_AIR){
foundBottom = true;
return;
}

if (!destroyBlock(level, miningPos.immutable(), true, null, Items.NETHERITE_PICKAXE.getDefaultInstance())){
stopped = true;
return;
}
stack.shrink(1);
}
} else {
if (getMachineState() == MachineState.ACTIVE) setMachineState(MachineState.IDLE);
}
}

public boolean destroyBlock(Level level, BlockPos pos, boolean dropBlock, @Nullable Entity entity, ItemStack item) {
BlockState blockstate = level.getBlockState(pos);
if (blockstate.isAir() || blockstate.getDestroySpeed(level, pos) < 0) {
if (blockstate.getDestroySpeed(level, pos) < 0) {
return false;
} else {
FluidState fluidstate = level.getFluidState(pos);
Expand All @@ -76,12 +89,27 @@ public boolean destroyBlock(Level level, BlockPos pos, boolean dropBlock, @Nulla
}
}

boolean flag = level.setBlock(pos, Blocks.AIR.defaultBlockState(), 3, 512);
/*if (flag) {
level.gameEvent(GameEvent.BLOCK_DESTROY, pos, GameEvent.Context.of(entity, blockstate));
}*/
boolean flag = level.setBlock(pos, MINING_PIPE.defaultBlockState(), 3, 512) || blockstate.getBlock() == MINING_PIPE;
if (flag && pos.getY() + 1 < this.getBlockPos().getY()) {
level.setBlock(pos.above(), MINING_PIPE_THIN.defaultBlockState(), 11);
//level.gameEvent(GameEvent.BLOCK_DESTROY, pos, GameEvent.Context.of(entity, blockstate));
}

return flag;
}
}

@Override
public void saveAdditional(CompoundTag tag) {
super.saveAdditional(tag);
tag.putBoolean("foundBottom", foundBottom);
tag.putLong("miningPos", miningPos.asLong());
}

@Override
public void load(CompoundTag tag) {
super.load(tag);
this.foundBottom = nbt.getBoolean("foundBottom");
this.miningPos = BlockPos.of(nbt.getLong("miningPos")).mutable();
}
}

0 comments on commit 938fd0c

Please sign in to comment.