Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master-1.19-lts' into master-1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Apr 22, 2023
2 parents 8c05a11 + c9e1b24 commit b0c4443
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 15 deletions.
6 changes: 6 additions & 0 deletions resources/changelog/1.18.2-1.9.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
As always, don't forget to backup your world before updating!
Requires CyclopsCore version 1.13.4 or higher.

Additions:
* Restore different sound pitches based on chest size, Closes #159
* Make chest inventory size material factors configurable, Closes #117
6 changes: 6 additions & 0 deletions resources/changelog/1.19.2-1.9.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
As always, don't forget to backup your world before updating!
Requires CyclopsCore version 1.17.0 or higher.

Additions:
* Restore different sound pitches based on chest size, Closes #159
* Make chest inventory size material factors configurable, Closes #117
15 changes: 15 additions & 0 deletions src/main/java/org/cyclops/colossalchests/GeneralConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ public class GeneralConfig extends DummyConfig {
@ConfigurableProperty(category = "general", comment = "Always create full creative-mode chests when formed. Should not be used in survival worlds!", isCommandable = true, configLocation = ModConfig.Type.SERVER)
public static boolean creativeChests = false;

@ConfigurableProperty(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfig.Type.SERVER)
public static double chestInventoryMaterialFactorWood = 1;
@ConfigurableProperty(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfig.Type.SERVER)
public static double chestInventoryMaterialFactorCopper = 1.666;
@ConfigurableProperty(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfig.Type.SERVER)
public static double chestInventoryMaterialFactorIron = 2;
@ConfigurableProperty(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfig.Type.SERVER)
public static double chestInventoryMaterialFactorSilver = 2.666;
@ConfigurableProperty(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfig.Type.SERVER)
public static double chestInventoryMaterialFactorGold = 3;
@ConfigurableProperty(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfig.Type.SERVER)
public static double chestInventoryMaterialFactorDiamond = 4;
@ConfigurableProperty(category = "general", comment = "Multiplier for the number of inventory slots for this chest material.", isCommandable = true, configLocation = ModConfig.Type.SERVER)
public static double chestInventoryMaterialFactorObsidian = 4;

public GeneralConfig() {
super(ColossalChests._instance, "general");
}
Expand Down
22 changes: 12 additions & 10 deletions src/main/java/org/cyclops/colossalchests/block/ChestMaterial.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.common.collect.Maps;
import net.minecraft.core.Vec3i;
import net.minecraft.world.inventory.MenuType;
import org.cyclops.colossalchests.GeneralConfig;
import org.cyclops.colossalchests.Reference;
import org.cyclops.colossalchests.blockentity.BlockEntityColossalChest;
import org.cyclops.colossalchests.inventory.container.ContainerColossalChest;
Expand All @@ -17,6 +18,7 @@

import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

/**
* @author rubensworks
Expand All @@ -26,16 +28,16 @@ public class ChestMaterial {
public static final List<ChestMaterial> VALUES = Lists.newArrayList();
public static final Map<String, ChestMaterial> KEYED_VALUES = Maps.newHashMap();

public static final ChestMaterial WOOD = new ChestMaterial("wood", 1);
public static final ChestMaterial COPPER = new ChestMaterial("copper", 1.666);
public static final ChestMaterial IRON = new ChestMaterial("iron", 2);
public static final ChestMaterial SILVER = new ChestMaterial("silver", 2.666);
public static final ChestMaterial GOLD = new ChestMaterial("gold", 3);
public static final ChestMaterial DIAMOND = new ChestMaterial("diamond", 4);
public static final ChestMaterial OBSIDIAN = new ChestMaterial("obsidian", 4);
public static final ChestMaterial WOOD = new ChestMaterial("wood", () -> GeneralConfig.chestInventoryMaterialFactorWood);
public static final ChestMaterial COPPER = new ChestMaterial("copper", () -> GeneralConfig.chestInventoryMaterialFactorCopper);
public static final ChestMaterial IRON = new ChestMaterial("iron", () -> GeneralConfig.chestInventoryMaterialFactorIron);
public static final ChestMaterial SILVER = new ChestMaterial("silver", () -> GeneralConfig.chestInventoryMaterialFactorSilver);
public static final ChestMaterial GOLD = new ChestMaterial("gold", () -> GeneralConfig.chestInventoryMaterialFactorGold);
public static final ChestMaterial DIAMOND = new ChestMaterial("diamond", () -> GeneralConfig.chestInventoryMaterialFactorDiamond);
public static final ChestMaterial OBSIDIAN = new ChestMaterial("obsidian", () -> GeneralConfig.chestInventoryMaterialFactorObsidian);

private final String name;
private final double inventoryMultiplier;
private final Supplier<Double> inventoryMultiplier;
private final int index;

private ColossalChest blockCore;
Expand All @@ -44,7 +46,7 @@ public class ChestMaterial {
private CubeDetector chestDetector = null;
private MenuType<ContainerColossalChest> container;

public ChestMaterial(String name, double inventoryMultiplier) {
public ChestMaterial(String name, Supplier<Double> inventoryMultiplier) {
this.name = name;
this.inventoryMultiplier = inventoryMultiplier;
this.index = ChestMaterial.VALUES.size();
Expand All @@ -61,7 +63,7 @@ public String getName() {
}

public double getInventoryMultiplier() {
return this.inventoryMultiplier;
return this.inventoryMultiplier.get();
}

public String getUnlocalizedName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ public class BlockEntityColossalChest extends CyclopsBlockEntity implements Menu

private final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() {
protected void onOpen(Level level, BlockPos pos, BlockState blockState) {
BlockEntityColossalChest.playSound(level, pos, blockState, SoundEvents.CHEST_OPEN);
BlockEntityColossalChest.playSound(level, pos, blockState, SoundEvents.CHEST_OPEN, getSizeSingular());
}

protected void onClose(Level level, BlockPos pos, BlockState blockState) {
BlockEntityColossalChest.playSound(level, pos, blockState, SoundEvents.CHEST_CLOSE);
BlockEntityColossalChest.playSound(level, pos, blockState, SoundEvents.CHEST_CLOSE, getSizeSingular());
}

protected void openerCountChanged(Level level, BlockPos pos, BlockState blockState, int p_155364_, int p_155365_) {
Expand Down Expand Up @@ -438,8 +438,11 @@ public AbstractContainerMenu createMenu(int id, Inventory playerInventory, Playe
return new ContainerColossalChest(id, playerInventory, this.getInventory());
}

static void playSound(Level level, BlockPos pos, BlockState blockState, SoundEvent soundEvent) {
level.playSound((Player)null, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, soundEvent, SoundSource.BLOCKS, 0.5F, level.random.nextFloat() * 0.1F + 0.9F);
static void playSound(Level level, BlockPos pos, BlockState blockState, SoundEvent soundEvent, int size) {
float increaseAngle = 0.15F / Math.min(5, size);
level.playSound((Player)null, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, soundEvent, SoundSource.BLOCKS,
(float) (0.5F + (0.5F * Math.log(size))),
level.random.nextFloat() * 0.1F + 0.45F + increaseAngle);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void saveAdditional(CompoundTag tag) {
}

static void playSound(Level level, BlockPos pos, BlockState blockState, SoundEvent soundEvent) {
level.playSound((Player)null, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, soundEvent, SoundSource.BLOCKS, 0.5F, level.random.nextFloat() * 0.1F + 0.9F);
level.playSound((Player)null, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, soundEvent, SoundSource.BLOCKS, 0.5F, level.random.nextFloat() * 0.2F + 1.15F);
}

@Override
Expand Down

0 comments on commit b0c4443

Please sign in to comment.