Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/main/java/io/github/pylonmc/pylon/PylonItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,17 @@ private PylonItems() {
.addButton(new MachineRecipesButton(HammerRecipe.RECIPE_TYPE));
}

public static final ItemStack BRONZE_HAMMER = ItemStackBuilder.rebarWeapon(Material.DIAMOND_PICKAXE, PylonKeys.BRONZE_HAMMER, true, true, false)
.set(DataComponentTypes.USE_COOLDOWN, UseCooldown.useCooldown(0.00001f)
.cooldownGroup(PylonKeys.HAMMER)
.build())
.set(DataComponentTypes.ITEM_MODEL, Material.GOLDEN_PICKAXE.getKey())
.noTool().build();
static {
RebarItem.register(Hammer.class, BRONZE_HAMMER);
PylonPages.TOOLS.addItem(BRONZE_HAMMER);
}

public static final ItemStack DIAMOND_HAMMER = ItemStackBuilder.rebarWeapon(Material.DIAMOND_PICKAXE, PylonKeys.DIAMOND_HAMMER, true, true, false)
.set(DataComponentTypes.USE_COOLDOWN, UseCooldown.useCooldown(0.00001f)
.cooldownGroup(PylonKeys.HAMMER)
Expand All @@ -983,6 +994,18 @@ private PylonItems() {
.addButton(new MachineRecipesButton(HammerRecipe.RECIPE_TYPE));
}


public static final ItemStack STEEL_HAMMER = ItemStackBuilder.rebarWeapon(Material.DIAMOND_PICKAXE, PylonKeys.STEEL_HAMMER, true, true, false)
.set(DataComponentTypes.USE_COOLDOWN, UseCooldown.useCooldown(0.00001f)
.cooldownGroup(PylonKeys.HAMMER)
.build())
.set(DataComponentTypes.ITEM_MODEL, Material.NETHERITE_PICKAXE.getKey())
.noTool().build();
static {
RebarItem.register(Hammer.class, STEEL_HAMMER);
PylonPages.TOOLS.addItem(STEEL_HAMMER);
}

public static final ItemStack BRONZE_AXE = ItemStackBuilder.rebarToolWeapon(Material.STONE_AXE, PylonKeys.BRONZE_AXE, RebarUtils.axeMineable(), true, false, true)
.set(DataComponentTypes.ITEM_MODEL, Material.GOLDEN_AXE.getKey())
.build();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/github/pylonmc/pylon/PylonKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ public class PylonKeys {
public static final NamespacedKey HAMMER = pylonKey("hammer");
public static final NamespacedKey STONE_HAMMER = pylonKey("stone_hammer");
public static final NamespacedKey IRON_HAMMER = pylonKey("iron_hammer");
public static final NamespacedKey BRONZE_HAMMER = pylonKey("bronze_hammer");
public static final NamespacedKey DIAMOND_HAMMER = pylonKey("diamond_hammer");
public static final NamespacedKey STEEL_HAMMER = pylonKey("steel_hammer");

public static final NamespacedKey WATERING_CAN = pylonKey("watering_can");
public static final NamespacedKey SPRINKLER = pylonKey("sprinkler");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void updateHammerTip(ItemStack newItem) {
getHammerTip().setItemStack(null);
return;
}
getHammerTip().setItemStack(ItemStackBuilder.of(hammer.baseBlock)
getHammerTip().setItemStack(ItemStackBuilder.of(hammer.baseBlock.createItemStack())
.addCustomModelDataString(getKey() + ":hammer_tip:" + hammer.getKey().key())
.build()
);
Expand Down Expand Up @@ -199,7 +199,7 @@ public void tick() {
}

Block baseBlock = getBlock().getRelative(BlockFace.DOWN, 3);
if (BlockStorage.isRebarBlock(baseBlock) || baseBlock.getType() != hammer.baseBlock) {
if (BlockStorage.isRebarBlock(baseBlock) || !hammer.baseBlock.matches(baseBlock)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void updateHammerTip(ItemStack newItem) {
getHammerTip().setItemStack(null);
return;
}
getHammerTip().setItemStack(ItemStackBuilder.of(hammer.baseBlock)
getHammerTip().setItemStack(ItemStackBuilder.of(hammer.baseBlock.createItemStack())
.addCustomModelDataString(getKey() + ":hammer_tip:" + hammer.getKey().key())
.build()
);
Expand All @@ -157,7 +157,7 @@ public void tick() {
}

Block baseBlock = getBlock().getRelative(BlockFace.DOWN, 3);
if (BlockStorage.isRebarBlock(baseBlock) || baseBlock.getType() != hammer.baseBlock) {
if (BlockStorage.isRebarBlock(baseBlock) || !hammer.baseBlock.matches(baseBlock)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public Collimator(@NotNull Block block, @NotNull BlockCreateContext context) {
createFluidPoint(FluidPointType.INPUT, BlockFace.NORTH, context, false);
setCapacity(obscyraPerCohesiveUnit);
setMultiblockDirection(context.getFacing());
setTickInterval(tickInterval);
startProcess(secondsPerCohesiveUnit * 20);
}

Expand All @@ -93,7 +94,7 @@ public boolean isAllowedFluid(@NotNull RebarFluid fluid) {

@Override
public void tick() {
double obscyraToUse = (double) obscyraPerCohesiveUnit / (secondsPerCohesiveUnit * getTickInterval());
double obscyraToUse = (double) obscyraPerCohesiveUnit / (secondsPerCohesiveUnit * 20.0 / getTickInterval());
if (isFormedAndFullyLoaded()
&& getFluidAmount() > obscyraToUse
&& inventory.canHold(PylonItems.COHESIVE_UNIT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.github.pylonmc.rebar.block.context.BlockCreateContext;
import io.github.pylonmc.rebar.entity.display.ItemDisplayBuilder;
import io.github.pylonmc.rebar.entity.display.transform.TransformBuilder;
import io.github.pylonmc.rebar.item.builder.ItemStackBuilder;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.persistence.PersistentDataContainer;
Expand All @@ -16,7 +17,10 @@ public class CollimatorPillar extends RebarBlock implements EntityHolderRebarBlo
public CollimatorPillar(@NotNull Block block, @NotNull BlockCreateContext context) {
super(block, context);
addEntity("display", new ItemDisplayBuilder()
.material(Material.YELLOW_TERRACOTTA)
.itemStack(
ItemStackBuilder.of(Material.YELLOW_TERRACOTTA)
.addCustomModelDataString(getKey().toString())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.addCustomModelDataString(getKey().toString())
.addCustomModelDataString(getKey() + ":display")

)
.transformation(new TransformBuilder()
.translate(0, 1.01, 0)
.scale(0.35, 2, 0.35))
Expand Down
30 changes: 8 additions & 22 deletions src/main/java/io/github/pylonmc/pylon/content/tools/Hammer.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.github.pylonmc.pylon.content.tools;

import com.destroystokyo.paper.ParticleBuilder;
import io.github.pylonmc.pylon.PylonKeys;
import io.github.pylonmc.pylon.content.assembling.AssemblyTable;
import io.github.pylonmc.pylon.content.machines.smelting.BronzeAnvil;
import io.github.pylonmc.pylon.recipes.HammerRecipe;
import io.github.pylonmc.rebar.block.BlockStorage;
import io.github.pylonmc.rebar.block.BlockTypeWrapper;
import io.github.pylonmc.rebar.block.RebarBlock;
import io.github.pylonmc.rebar.block.interfaces.GuiRebarBlock;
import io.github.pylonmc.rebar.block.interfaces.NoVanillaInventoryRebarBlock;
Expand All @@ -23,7 +23,6 @@
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Particle;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
Expand Down Expand Up @@ -51,6 +50,7 @@
import java.util.UUID;

public class Hammer extends RebarItem implements BlockInteractRebarItemHandler {
private static final ConfigAdapter<MiningLevel> MINING_LEVEL_ADAPTER = ConfigAdapter.ENUM.from(MiningLevel.class);
private static final Map<BlockPosition, Pair<HammerRecipe, UUID>> lastHammeredItems = new HashMap<>();
public static final Random random = new Random();

Expand All @@ -59,8 +59,8 @@ public class Hammer extends RebarItem implements BlockInteractRebarItemHandler {
// is fine because the memory usage is so tiny and it would be very annoying to fix
public static final Map<UUID, Integer> remainingUseMap = new HashMap<>();

public final Material baseBlock = getBaseBlock(getKey());
public final MiningLevel miningLevel = getMiningLevel(getKey());
public final BlockTypeWrapper baseBlock = getSettingOrThrow("base-block", ConfigAdapter.BLOCK_TYPE_WRAPPER);
public final MiningLevel miningLevel = getSettingOrThrow("mining-level", MINING_LEVEL_ADAPTER);
public final int cooldownTicks = getSettingOrThrow("cooldown-ticks", ConfigAdapter.INTEGER);
public final RandomizedSound sound = getSettingOrThrow("sound", ConfigAdapter.RANDOMIZED_SOUND);
public final RandomizedSound failSound = getSettingOrThrow("fail-sound", ConfigAdapter.RANDOMIZED_SOUND);
Expand All @@ -70,7 +70,7 @@ public Hammer(@NotNull ItemStack stack) {
}

public boolean tryDoRecipe(@NotNull Block block, @Nullable Player player, @Nullable EquipmentSlot slot) {
if (baseBlock != block.getType()) {
if (!baseBlock.matches(block)) {
if (player != null && !(BlockStorage.get(block) instanceof BronzeAnvil)) {
player.sendMessage(Component.translatable("pylon.message.hammer_cant_use"));
}
Expand Down Expand Up @@ -130,6 +130,7 @@ private boolean tryDoRecipe(Block block, Player player, EquipmentSlot slot, Hamm
}

if (player != null) {
player.swingHand(slot);
player.setCooldown(getStack(), cooldownTicks);
RebarUtils.damageItem(getStack(), 1, player, slot);
} else {
Expand Down Expand Up @@ -256,23 +257,8 @@ public boolean respectCooldown() {
@Override
public @NotNull List<@NotNull RebarArgument> getPlaceholders() {
return List.of(
RebarArgument.of("base-block", baseBlock.createItemStack().effectiveName()),
RebarArgument.of("cooldown", UnitFormat.SECONDS.format(cooldownTicks / 20.0))
);
}

private static Material getBaseBlock(@NotNull NamespacedKey key) {
return Map.of(
PylonKeys.STONE_HAMMER, Material.STONE,
PylonKeys.IRON_HAMMER, Material.IRON_BLOCK,
PylonKeys.DIAMOND_HAMMER, Material.DIAMOND_BLOCK
).get(key);
}

private static MiningLevel getMiningLevel(@NotNull NamespacedKey key) {
return Map.of(
PylonKeys.STONE_HAMMER, MiningLevel.STONE,
PylonKeys.IRON_HAMMER, MiningLevel.IRON,
PylonKeys.DIAMOND_HAMMER, MiningLevel.DIAMOND
).get(key);
}
}
}
21 changes: 18 additions & 3 deletions src/main/resources/lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -524,24 +524,38 @@ item:
name: "Grindstone Handle"
lore: "<star> Grindstone multiblock component"

steel_hammer:
name: "Steel Hammer"
lore: |-
<arrow> <insn>Right click</insn> an item dropped on top of a placed <white>%base-block%</white> to use the hammer on it
<arrow> Higher tier hammers are twice as likely to succeed than the tier below them for a given recipe
<arrow> <attr>Cooldown:</attr> %cooldown%

diamond_hammer:
name: "Diamond Hammer"
lore: |-
<arrow> <insn>Right click</insn> an item dropped on top of a placed <white>block of diamond</white> to use the hammer on it
<arrow> <insn>Right click</insn> an item dropped on top of a placed <white>%base-block%</white> to use the hammer on it
<arrow> Higher tier hammers are twice as likely to succeed than the tier below them for a given recipe
<arrow> <attr>Cooldown:</attr> %cooldown%

bronze_hammer:
name: "Bronze Hammer"
lore: |-
<arrow> <insn>Right click</insn> an item dropped on top of a placed <white>%base-block%</white> to use the hammer on it
<arrow> Higher tier hammers are twice as likely to succeed than the tier below them for a given recipe
<arrow> <attr>Cooldown:</attr> %cooldown%

iron_hammer:
name: "Iron Hammer"
lore: |-
<arrow> <insn>Right click</insn> an item dropped on top of a placed <white>block of iron</white> to use the hammer on it
<arrow> <insn>Right click</insn> an item dropped on top of a placed <white>%base-block%</white> to use the hammer on it
<arrow> Higher tier hammers are twice as likely to succeed than the tier below them for a given recipe
<arrow> <attr>Cooldown:</attr> %cooldown%

stone_hammer:
name: "Stone Hammer"
lore: |-
<arrow> <insn>Right click</insn> an item dropped on top of a placed <white>stone block</white> to use the hammer on it
<arrow> <insn>Right click</insn> an item dropped on top of a placed <white>%base-block%</white> to use the hammer on it
<arrow> Higher tier hammers are twice as likely to succeed than the tier below them for a given recipe
<arrow> <attr>Cooldown:</attr> %cooldown%

Expand Down Expand Up @@ -2134,6 +2148,7 @@ item:
collimator:
name: "Collimator"
lore: |-
<star> Multiblock
<arrow> Slowly synthesizes Cohesive Units
<arrow> Only works below <white>y = 0
<arrow> <attr>Obscyra per Cohesive Unit:</attr> %obscyra-per-cohesive-unit%
Expand Down
22 changes: 22 additions & 0 deletions src/main/resources/recipes/minecraft/crafting_shaped.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,17 @@ pylon:iron_hammer:
result: pylon:iron_hammer
category: equipment

pylon:bronze_hammer:
pattern:
- " M "
- " SM"
- "S "
key:
M: pylon:bronze_ingot
S: minecraft:stick
result: pylon:bronze_hammer
category: equipment

pylon:diamond_hammer:
pattern:
- " M "
Expand All @@ -1634,6 +1645,17 @@ pylon:diamond_hammer:
result: pylon:diamond_hammer
category: equipment

pylon:steel_hammer:
pattern:
- " M "
- " SM"
- "S "
key:
M: pylon:steel_ingot
S: minecraft:stick
result: pylon:steel_hammer
category: equipment

pylon:vacuum_hopper_1:
pattern:
- "S S"
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/researches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ bronze_equipment:
- pylon:bronze_leggings
- pylon:bronze_chestplate
- pylon:bronze_helmet
- pylon:bronze_hammer

improved_hammers:
item: pylon:iron_hammer
Expand Down Expand Up @@ -655,6 +656,7 @@ steel_tools:
- pylon:steel_pickaxe
- pylon:steel_shovel
- pylon:steel_hoe
- pylon:steel_hammer

steel_armor:
item: pylon:steel_chestplate
Expand Down
20 changes: 20 additions & 0 deletions src/main/resources/settings/bronze_hammer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cooldown-ticks: 28
durability: 453
attack-durability-damage: 1
attack-speed: 0.75
attack-damage: 4
attack-knockback: 1.75

base-block: pylon:bronze_block
mining-level: DIAMOND

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mining-level: DIAMOND
mining-level: diamond # can be any, wood, gold, stone, iron, diamond or netherite.


sound:
sound: minecraft:block.anvil.use
source: block
volume: 0.5
pitch: 0.5
fail-sound:
sound: minecraft:block.anvil.land
source: block
volume: 0.25
pitch: 0.8
4 changes: 4 additions & 0 deletions src/main/resources/settings/diamond_hammer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ attack-durability-damage: 1
attack-speed: 1
attack-damage: 5
attack-knockback: 2

base-block: minecraft:diamond_block
mining-level: DIAMOND

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mining-level: DIAMOND
mining-level: diamond # can be any, wood, gold, stone, iron, diamond or netherite.


sound:
sound: minecraft:block.anvil.use
source: block
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/settings/iron_hammer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ attack-durability-damage: 1
attack-speed: 0.5
attack-damage: 3
attack-knockback: 1.5

base-block: minecraft:iron_block
mining-level: IRON

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mining-level: IRON
mining-level: iron # can be any, wood, gold, stone, iron, diamond or netherite.


sound:
sound: minecraft:block.anvil.use
source: block
Expand Down
20 changes: 20 additions & 0 deletions src/main/resources/settings/steel_hammer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cooldown-ticks: 20
durability: 1197
attack-durability-damage: 1
attack-speed: 1.2
attack-damage: 7
attack-knockback: 3

base-block: pylon:steel_block
mining-level: NETHERITE

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mining-level: NETHERITE
mining-level: netherite # can be any, wood, gold, stone, iron, diamond or netherite.


sound:
sound: minecraft:block.anvil.use
source: block
volume: 0.5
pitch: 0.5
fail-sound:
sound: minecraft:block.anvil.land
source: block
volume: 0.25
pitch: 0.8
4 changes: 4 additions & 0 deletions src/main/resources/settings/stone_hammer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ attack-durability-damage: 1
attack-speed: 0.33
attack-damage: 1
attack-knockback: 1

base-block: minecraft:stone
mining-level: STONE

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mining-level: STONE
mining-level: stone # can be any, wood, gold, stone, iron, diamond or netherite.


sound:
sound: minecraft:block.anvil.use
source: block
Expand Down
Loading