Skip to content

Commit

Permalink
merge/1.16 upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
Lothrazar committed Nov 10, 2024
2 parents 4f6c15d + a3dabfc commit 15d468a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
18 changes: 10 additions & 8 deletions src/main/java/com/lothrazar/cyclic/config/ConfigRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,21 +410,18 @@ private static void initConfig() {
CABLE_FACADES = CFG.comment("\r\n Allow cables to have blocks placed in them as facades (sneak-left-click to set; use empty hand to remove). Set to false to disable facades")
.define("cables.enabled", true);
//a few default
List<String> list = Arrays.asList("minecraft:ladder", "minecraft:double_plant", "minecraft:waterlily",
List<String> list = Arrays.asList("minecraft:double_plant", "minecraft:waterlily",
"minecraft:torch", "minecraft:*_torch", "minecraft:redstone", "minecraft:iron_bars",
"minecraft:chest", "minecraft:ender_chest", "minecraft:sculk_vein", "minecraft:string", "minecraft:vine",
"minecraft:rail",
"minecraft:*_rail",
"minecraft:brewing_stand",
"minecraft:*_dripleaf",
"minecraft:*_pane",
"minecraft:*_sapling", "minecraft:*_sign",
"minecraft:*_door",
"minecraft:*_banner", "minecraft:*_shulker_box",
"cyclic:*_pipe", "cyclic:*_bars",
"storagenetwork:*");
FACADE_IGNORELIST = CFG.comment("\r\n These blocks are not allowed to be used as Facades for blocks because they look weird (used by cables and Glowstone Facade and Soundproofing Facade and others)")
.define("itemsNotAllowed", list);
FACADE_IGNORELIST = CFG.comment("\r\n These blocks are not allowed to be used as Facades for blocks because they look weird (used by cables and Glowstone Facade and Soundproofing Facade and others). If you want to ignore one entire mod use an entry like this : storagenetwork:* ")
.defineList("itemsNotAllowed", list, it -> it instanceof String);
CFG.pop();
//
TRANSFER_NODES_DIMENSIONAL = CFG.comment(" Allows the dimensional Transfer Nodes to cross dimensions "
Expand Down Expand Up @@ -639,6 +636,11 @@ public static List<String> getGloomIgnoreList() {
return (List<String>) GLOOM_IGNORE_LIST.get();
}

@SuppressWarnings("unchecked")
public static List<String> getFacadeIgnoreList() {
return (List<String>) FACADE_IGNORELIST.get();
}

public static Map<String, String> getMappedBeheading() {
Map<String, String> mappedBeheading = new HashMap<String, String>();
for (String s : BEHEADING_SKINS.get()) {
Expand All @@ -656,11 +658,11 @@ public static Map<String, String> getMappedBeheading() {
}

public static BooleanValue CABLE_FACADES;
private static ConfigValue<List<String>> FACADE_IGNORELIST;
private static ConfigValue<List<? extends String>> FACADE_IGNORELIST;

public static boolean isFacadeAllowed(ItemStack item) {
ResourceLocation itemId = ForgeRegistries.ITEMS.getKey(item.getItem());
if (StringParseUtil.isInList(FACADE_IGNORELIST.get(), itemId)) {
if (StringParseUtil.isInList(getFacadeIgnoreList(), itemId)) {
return false;
}
return true;
Expand Down
32 changes: 26 additions & 6 deletions src/main/java/com/lothrazar/cyclic/util/FluidHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.minecraft.world.inventory.InventoryMenu;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LayeredCauldronBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
Expand Down Expand Up @@ -48,6 +49,12 @@ public static class FluidAttributes {
public static final int BUCKET_VOLUME = net.minecraftforge.fluids.FluidType.BUCKET_VOLUME;
}

/**
* maps fluid to colour hex code as int value. Used by itemstack durability bar on filled held tanks
*
* @param fstack
* @return
*/
public static int getColorFromFluid(FluidStack fstack) {
if (fstack != null && fstack.getFluid() != null) {
//first check mine
Expand All @@ -65,10 +72,7 @@ else if (fstack.getFluid() == FluidSlimeHolder.STILL.get()) {
}
else if (fstack.getFluid() == FluidXpJuiceHolder.STILL.get()) {
return FluidXpJuiceHolder.COLOR;
} //now check if the fluid has a color
// else if (fstack.getFluid().getAttributes().getColor() > 0) {
// return fstack.getFluid().getAttributes().getColor();
// }
}
else if (fstack.getFluid() == ForgeMod.MILK.get()) {
return COLOUR_MILK;
}
Expand All @@ -80,6 +84,11 @@ else if (fstack.getFluid() == Fluids.LAVA) {
}

/**
* Internally knows that water cauldrons fil to level 3, but lava cauldrons are a different block without the level property.
*
* Ignores partially filled water cauldrons.
*
* a full cauldron is 1000mb
*
* @param level
* @param posTarget
Expand All @@ -96,7 +105,7 @@ public static boolean insertSourceCauldron(Level level, BlockPos posTarget, IFlu
FluidStack simulate = tank.drain(new FluidStack(new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME), FluidAttributes.BUCKET_VOLUME), FluidAction.SIMULATE);
if (simulate.getAmount() == FluidAttributes.BUCKET_VOLUME) {
//we are able to fill the tank
if (level.setBlock(posTarget, Blocks.WATER_CAULDRON.defaultBlockState(), 3)) {
if (level.setBlock(posTarget, Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), 3)) {
//we filled the cauldron, so now drain with execute
tank.drain(new FluidStack(new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME), FluidAttributes.BUCKET_VOLUME), FluidAction.EXECUTE);
return true;
Expand All @@ -116,6 +125,17 @@ public static boolean insertSourceCauldron(Level level, BlockPos posTarget, IFlu
return false;
}

/**
* Internally knows that water cauldrons fil to level 3, but lava cauldrons are a different block without the level property.
*
* Ignores partially filled water cauldrons.
*
* a full cauldron is 1000mb
*
* @param level
* @param posTarget
* @param tank
*/
public static void extractSourceWaterloggedCauldron(Level level, BlockPos posTarget, IFluidHandler tank) {
if (tank == null) {
return;
Expand All @@ -132,7 +152,7 @@ public static void extractSourceWaterloggedCauldron(Level level, BlockPos posTar
tank.fill(new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME), FluidAction.EXECUTE);
}
}
else if (targetState.getBlock() == Blocks.WATER_CAULDRON) {
else if (targetState.getBlock() == Blocks.WATER_CAULDRON && targetState.getValue(LayeredCauldronBlock.LEVEL) >= 3) {
int simFill = tank.fill(new FluidStack(new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME), FluidAttributes.BUCKET_VOLUME), FluidAction.SIMULATE);
if (simFill == FluidAttributes.BUCKET_VOLUME
&& level.setBlockAndUpdate(posTarget, Blocks.CAULDRON.defaultBlockState())) {
Expand Down

0 comments on commit 15d468a

Please sign in to comment.