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

Commit

Permalink
fixed charcoal pit recipe, started work on charcoal pit
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Jul 27, 2023
1 parent 830a604 commit d4209c8
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 5 deletions.
9 changes: 9 additions & 0 deletions common/src/main/java/muramasa/gregtech/data/GregTechData.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import muramasa.antimatter.AntimatterAPI;
import muramasa.antimatter.AntimatterConfig;
import muramasa.antimatter.Ref;
import muramasa.antimatter.block.BlockBasic;
import muramasa.antimatter.cover.CoverFactory;
import muramasa.antimatter.data.AntimatterMaterialTypes;
import muramasa.antimatter.data.AntimatterMaterials;
Expand All @@ -25,6 +26,7 @@
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 @@ -273,6 +275,13 @@ public ItemStack pickupBlock(LevelAccessor level, BlockPos pos, BlockState state

//public static BlockBasic ANTHRACITE_COAL = new BlockBasic(GTIRef.ID, "anthracite_coal", new Texture(GTIRef.ID, "block/basic/anthracite_coal");
//public static BlockBasic ANTHRACITE_COAL = new BlockBasic(GTIRef.ID, "anthracite_coal", new Texture(GTIRef.ID, "block/basic/anthracite_coal");

public static final BlockBasic BRITTLE_CHARCOAL = new BlockBasic(GTIRef.ID, "brittle_charcoal", BlockBehaviour.Properties.of(net.minecraft.world.level.material.Material.WOOD, MaterialColor.COLOR_BLACK).requiresCorrectToolForDrops().strength(5.0F, 6.0F)){
@Override
public Texture[] getTextures() {
return new Texture[]{new Texture("minecraft:block/coal_block")};
}
};
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
3 changes: 2 additions & 1 deletion common/src/main/java/muramasa/gregtech/data/Machines.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import muramasa.antimatter.data.AntimatterMaterials;
import muramasa.antimatter.machine.Tier;
import muramasa.antimatter.machine.types.*;
import muramasa.antimatter.texture.Texture;
import muramasa.antimatter.tile.single.TileEntityBatteryBuffer;
import muramasa.antimatter.tile.single.TileEntityDigitalTransformer;
import muramasa.antimatter.tile.single.TileEntityTransformer;
Expand Down Expand Up @@ -46,7 +47,7 @@ public class Machines {
/**
** Hatchless Multiblock Machines (Steam Age)
**/
public static BasicMultiMachine<?> CHARCOAL_PIT = new BasicMultiMachine<>(GTIRef.ID, "charcoal_pit").setTiers(BRONZE).setTile(TileEntityCharcoalPit::new);
public static BasicMachine CHARCOAL_PIT = new BasicMachine(GTIRef.ID, "charcoal_pit").setTiers(NONE).baseTexture(new Texture(GTIRef.ID, "block/machine/base/charcoal_pit")).setTile(TileEntityCharcoalPit::new);
public static BasicMultiMachine<?> COKE_OVEN = new BasicMultiMachine<>(GTIRef.ID, "coke_oven").setTiers(NONE).setMap(COKING).addFlags(GUI, ITEM, FLUID).setTile(TileEntityCokeOven::new);
public static BasicMultiMachine<?> PRIMITIVE_BLAST_FURNACE = new BasicMultiMachine<>(GTIRef.ID, "primitive_blast_furnace").setTiers(NONE).setMap(BASIC_BLASTING).addFlags(GUI, ITEM).setTile(TileEntityPrimitiveBlastFurnace::new);
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import muramasa.gregtech.block.BlockCasing;
import muramasa.gregtech.block.BlockCoil;
import muramasa.gregtech.block.BlockFakeCasing;
import muramasa.gregtech.data.GregTechData;

public class GregTechBlockTagProvider extends AntimatterBlockTagProvider {

Expand All @@ -26,5 +27,6 @@ public void processTags(String domain){
AntimatterAPI.all(BlockCoil.class, GTIRef.ID, cas -> {
this.tag(AntimatterDefaultTools.WRENCH.getToolType()).add(cas);
});
this.tag(AntimatterDefaultTools.AXE.getToolType()).add(GregTechData.BRITTLE_CHARCOAL);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import muramasa.gregtech.block.BlockCasing;
import muramasa.gregtech.block.BlockCoil;
import muramasa.gregtech.block.BlockFakeCasing;
import muramasa.gregtech.data.GregTechData;
import muramasa.gregtech.items.ItemIntCircuit;

import static muramasa.antimatter.util.Utils.*;
Expand Down Expand Up @@ -46,6 +47,7 @@ protected void english(String domain, String locale) {
add(i, lowerUnderscoreToUpperSpaced(i.getId()));
});

add(GregTechData.BRITTLE_CHARCOAL, "Brittle Charcoal");
AntimatterAPI.all(BlockFakeCasing.class, domain).forEach(i -> add(i, lowerUnderscoreToUpperSpaced(i.getId())));
AntimatterAPI.all(BlockCoil.class, domain).forEach(i -> add(i, lowerUnderscoreToUpperSpaced(i.getId())));
AntimatterAPI.all(ItemIntCircuit.class, domain).forEach(i -> add(i, "Integrated Circuit (" + i.circuitId + ")"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import muramasa.gregtech.data.Materials;
import muramasa.gregtech.integration.AppliedEnergisticsRegistrar;
import net.minecraft.data.DataGenerator;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Blocks;
Expand Down Expand Up @@ -50,6 +51,7 @@ protected void loot() {
tables.put(Blocks.DEEPSLATE_COPPER_ORE, b -> createOreDrop(b, RAW_ORE.get(Copper)));
tables.put(Blocks.COAL_ORE, b -> createOreDrop(b, RAW_ORE.get(Coal)));
tables.put(Blocks.DEEPSLATE_COAL_ORE, b -> createOreDrop(b, RAW_ORE.get(Coal)));
tables.put(GregTechData.BRITTLE_CHARCOAL, b -> createSingleItemTable(Items.CHARCOAL, UniformGenerator.between(1.0f, 2.0f)));
tables.put(Blocks.ANCIENT_DEBRIS, b -> createOreDrop(b, RAW_ORE.get(NetheriteScrap)));
tables.put(Blocks.ANDESITE, b -> createSingleItemTableWithSilkTouch(Blocks.ANDESITE, ((CobbleStoneType)AntimatterStoneTypes.ANDESITE).getBlock("cobble")));
tables.put(Blocks.DIORITE, b -> createSingleItemTableWithSilkTouch(Blocks.DIORITE, ((CobbleStoneType)AntimatterStoneTypes.DIORITE).getBlock("cobble")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,9 @@ public static void loadRecipes(Consumer<FinishedRecipe> output, AntimatterRecipe

provider.addItemRecipe(output, "machines", "has_wrench", provider.hasSafeItem(WRENCH.getTag()), CHARCOAL_PIT.getItem(CHARCOAL_PIT.getFirstTier()),
ImmutableMap.<Character, Object>builder()
.put('H', CASING_BRONZE_PLATED_BRICK)
.put('G', GEAR.get(Steel))
.put('B', Blocks.COAL_BLOCK).build(), "GHG", "HBH", "GHG");
.put('H', CASING_BRICKED_BRONZE)
.put('W', NUGGET.getMaterialTag(WroughtIron))
.put('F', Items.FLINT).build(), "WHW", "FFF");

provider.addItemRecipe(output, "machines", "has_wrench", provider.hasSafeItem(WRENCH.getTag()), PYROLYSIS_OVEN.getItem(PYROLYSIS_OVEN.getFirstTier()),
ImmutableMap.<Character, Object>builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,191 @@
package muramasa.gregtech.tile.multi;

import muramasa.antimatter.machine.Tier;
import muramasa.antimatter.machine.types.Machine;
import muramasa.antimatter.tile.TileEntityMachine;
import muramasa.antimatter.tile.multi.TileEntityMultiMachine;
import muramasa.antimatter.tool.AntimatterToolType;
import muramasa.gregtech.data.GregTechData;
import muramasa.gregtech.data.Machines;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.Nullable;

public class TileEntityCharcoalPit extends TileEntityMultiMachine<TileEntityCharcoalPit> {
import java.util.ArrayList;
import java.util.List;

public class TileEntityCharcoalPit extends TileEntityMachine<TileEntityCharcoalPit> {
List<BlockPos> blockLists = new ArrayList<>();
int progress = 0;
int maxProgress = 0;
boolean running = false;

public TileEntityCharcoalPit(Machine<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
}

@Override
public void serverTick(Level level, BlockPos pos, BlockState state) {
super.serverTick(level, pos, state);
if (maxProgress > 0 && !blockLists.isEmpty() & this.level != null){
if (++progress == maxProgress){
blockLists.forEach(b -> {
this.getLevel().setBlock(b, GregTechData.BRITTLE_CHARCOAL.defaultBlockState(), 3);
});
maxProgress = 0;
}
}
}

@Override
public InteractionResult onInteractBoth(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit, @Nullable AntimatterToolType type) {
if (player.getItemInHand(hand).getItem() == Items.FLINT_AND_STEEL){
if (maxProgress == 0 && checkRecursiveBlocks()){
return InteractionResult.SUCCESS;
}
}
return super.onInteractBoth(state, world, pos, player, hand, hit, type);
}

private boolean checkRecursiveBlocks() {
blockLists.clear();;
List<BlockPos> toCheck = new ArrayList<>();

BlockPos.MutableBlockPos mutableBlockPos = this.getBlockPos().mutable();
Block tBlock = this.getLevel().getBlockState(mutableBlockPos.move(0, -1, 0)).getBlock();
if (!isWoodLog(tBlock)) {
return false;
} else {
toCheck.add(mutableBlockPos.immutable());
}
while (!toCheck.isEmpty()) {
BlockPos tPos = toCheck.get(0);
toCheck.remove(0);
if (!checkAllBlockSides(tPos.getX(), tPos.getY(), tPos.getZ(), blockLists, toCheck)) {
return false;
}
}
this.maxProgress = (int) Math.sqrt(blockLists.size() * 240000);
return true;
}

private boolean checkAllBlockSides(int aX, int aY, int aZ, List<BlockPos> toAdd, List<BlockPos> toCheck) {
int x = this.getBlockPos().getX();
int y = this.getBlockPos().getY();
int z = this.getBlockPos().getZ();
boolean p1 = false;
boolean p2 = false;
boolean p3 = false;
boolean p4 = false;
boolean p5 = false;
boolean p6 = false;
Block tBlock = this.getLevel().getBlockState(new BlockPos(aX + 1, aY, aZ)).getBlock();
if (aX + 1 < x + 6 && (isWoodLog(tBlock))) {
if (!toAdd.contains(new BlockPos(aX + 1, aY, aZ)) && (!toCheck.contains(new BlockPos(aX + 1, aY, aZ))))
p1 = true;
} else if (!(tBlock.defaultBlockState().is(BlockTags.DIRT))) {
return false;
}

tBlock = this.getLevel().getBlockState(new BlockPos(aX - 1, aY, aZ)).getBlock();
if (aX - 1 > x - 6 && (isWoodLog(tBlock))) {
if (!toAdd.contains(new BlockPos(aX - 1, aY, aZ)) && (!toCheck.contains(new BlockPos(aX - 1, aY, aZ))))
p2 = true;
} else if (!(tBlock.defaultBlockState().is(BlockTags.DIRT))) {
return false;
}

tBlock = this.getLevel().getBlockState(new BlockPos(aX, aY + 1, aZ)).getBlock();
if (aY + 1 < y + 1 && (isWoodLog(tBlock))) {
if (!toAdd.contains(new BlockPos(aX, aY + 1, aZ)) && (!toCheck.contains(new BlockPos(aX, aY + 1, aZ))))
p3 = true;
}else if (!(tBlock.defaultBlockState().is(BlockTags.DIRT) ||
(aX == this.getBlockPos().getX() && aY == this.getBlockPos().getY() - 1 && aZ == this.getBlockPos().getZ() && tBlock == Machines.CHARCOAL_PIT.getBlockState(Tier.NONE)))) {
return false;
}

tBlock = this.getLevel().getBlockState(new BlockPos(aX, aY - 1, aZ)).getBlock();
if (aY - 1 > y - 6 && (isWoodLog(tBlock))) {
if (!toAdd.contains(new BlockPos(aX, aY - 1, aZ)) && (!toCheck.contains(new BlockPos(aX, aY - 1, aZ))))
p4 = true;
} else if (tBlock != Blocks.BRICKS) {
return false;
}

tBlock = this.getLevel().getBlockState(new BlockPos(aX, aY, aZ + 1)).getBlock();
if (aZ + 1 < z + 6 && (isWoodLog(tBlock))) {
if (!toAdd.contains(new BlockPos(aX, aY, aZ + 1)) && (!toCheck.contains(new BlockPos(aX, aY, aZ + 1))))
p5 = true;
} else if (!(tBlock.defaultBlockState().is(BlockTags.DIRT))) {
return false;
}

tBlock = this.getLevel().getBlockState(new BlockPos(aX, aY, aZ + 1)).getBlock();
if (aZ - 1 > z - 6 && (isWoodLog(tBlock))) {
if (!toAdd.contains(new BlockPos(aX, aY, aZ - 1)) && (!toCheck.contains(new BlockPos(aX, aY, aZ - 1))))
p6 = true;
} else if (!(tBlock.defaultBlockState().is(BlockTags.DIRT))) {
return false;
}
toAdd.add(new BlockPos(aX, aY, aZ));
if (p1) toCheck.add(new BlockPos(aX + 1, aY, aZ));
if (p2) toCheck.add(new BlockPos(aX - 1, aY, aZ));
if (p3) toCheck.add(new BlockPos(aX, aY + 1, aZ));
if (p4) toCheck.add(new BlockPos(aX, aY - 1, aZ));
if (p5) toCheck.add(new BlockPos(aX, aY, aZ + 1));
if (p6) toCheck.add(new BlockPos(aX, aY, aZ - 1));
return true;
}

public boolean isWoodLog(Block log){
return log.defaultBlockState().is(BlockTags.LOGS);
}

@Override
public void saveAdditional(CompoundTag tag) {
super.saveAdditional(tag);
if (maxProgress > 0){
tag.putInt("progress", progress);
tag.putInt("maxProgress", maxProgress);
}
ListTag listTag = new ListTag();
blockLists.forEach(b -> {
CompoundTag tag1 = new CompoundTag();
tag1.putInt("x", b.getX());
tag1.putInt("y", b.getY());
tag1.putInt("z", b.getZ());
listTag.add(tag1);
});
if (!listTag.isEmpty()){
tag.put("blockLists", listTag);
}
}

@Override
public void deserializeNBT(BlockState state, CompoundTag nbt) {
super.deserializeNBT(state, nbt);
if (nbt.contains("progress")){
progress = nbt.getInt("progress");
maxProgress = nbt.getInt("maxProgress");
}
if (nbt.contains("blockLists")){
ListTag listTag = nbt.getList("blockLists", 10);
listTag.forEach(t -> {
CompoundTag tag = (CompoundTag) t;
blockLists.add(new BlockPos(tag.getInt("x"), tag.getInt("y"), tag.getInt("z")));
});
}

}
}

0 comments on commit d4209c8

Please sign in to comment.