Skip to content

Commit

Permalink
Add more interactions + fixes for Lighter (#2075)
Browse files Browse the repository at this point in the history
  • Loading branch information
JuiceyBeans authored Oct 6, 2024
1 parent 6e4e1c3 commit b312167
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 30 deletions.
7 changes: 4 additions & 3 deletions src/generated/resources/assets/gtceu/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"behaviour.hammer": ")ɯǝɥʇ buıʇʇıɥ ʎq( sǝuıɥɔɐW ɹoɟ buıןɟɟnW ɟɟo puɐ uo suɹn⟘",
"behaviour.hoe": "ʇɹıp ןןıʇ uɐƆ",
"behaviour.lighter.fluid.tooltip": "ǝuɐdoɹԀ ɹo ǝuɐʇnᗺ ɥʇıʍ ǝɹıɟ uo sbuıɥʇ ʇɥbıן uɐƆ",
"behaviour.lighter.tooltip": "ǝɹıɟ uo sbuıɥʇ ʇɥbıן uɐƆ",
"behaviour.lighter.tooltip.description": "ǝɹıɟ uo sbuıɥʇ ʇɥbıן uɐƆ",
"behaviour.lighter.tooltip.usage": "ǝsoןɔ/uǝdo oʇ ʞɔıןɔ ʇɥbıɹ-ʇɟıɥS",
"behaviour.lighter.uses": "%d :sǝsn buıuıɐɯǝᴚ",
"behaviour.paintspray.black.tooltip": "ʞɔɐןᗺ uı sbuıɥʇ ʇuıɐd uɐƆ",
"behaviour.paintspray.blue.tooltip": "ǝnןᗺ uı sbuıɥʇ ʇuıɐd uɐƆ",
Expand Down Expand Up @@ -2589,8 +2590,8 @@
"effect.gtceu.weak_poison": "uosıoԀ ʞɐǝM",
"enchantment.damage.disjunction": "uoıʇɔunظsıᗡ",
"enchantment.disjunction": "uoıʇɔunظsıᗡ",
"enchantment.gtceu.disjunction.desc": "˙sqoɯ pǝʇɐןǝɹ-ɹǝpuƎ oʇ ssǝuʍoןS puɐ ssǝuʞɐǝM sǝıןddⱯ",
"enchantment.gtceu.hard_hammer.desc": "˙ɹǝɯɯɐH ɥɔǝ⟘bǝɹ⅁ ɐ ɥʇıʍ pǝuıɯ ǝɹǝʍ ʎǝɥʇ ɟı sɐ sʞɔoןq sʞɐǝɹᗺ",
"enchantment.gtceu.disjunction.description": "˙sqoɯ pǝʇɐןǝɹ-ɹǝpuƎ oʇ ssǝuʍoןS puɐ ssǝuʞɐǝM sǝıןddⱯ",
"enchantment.gtceu.hard_hammer.description": "˙ɹǝɯɯɐH ɥɔǝ⟘bǝɹ⅁ ɐ ɥʇıʍ pǝuıɯ ǝɹǝʍ ʎǝɥʇ ɟı sɐ sʞɔoןq sʞɐǝɹᗺ",
"enchantment.hard_hammer": "buıɹǝɯɯɐH",
"entity.gtceu.boat": "ʇɐoᗺ",
"entity.gtceu.chest_boat": "ʇɐoᗺ ʇsǝɥƆ",
Expand Down
7 changes: 4 additions & 3 deletions src/generated/resources/assets/gtceu/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"behaviour.hammer": "Turns on and off Muffling for Machines (by hitting them)",
"behaviour.hoe": "Can till dirt",
"behaviour.lighter.fluid.tooltip": "Can light things on fire with Butane or Propane",
"behaviour.lighter.tooltip": "Can light things on fire",
"behaviour.lighter.tooltip.description": "Can light things on fire",
"behaviour.lighter.tooltip.usage": "Shift-right click to open/close",
"behaviour.lighter.uses": "Remaining uses: %d",
"behaviour.paintspray.black.tooltip": "Can paint things in Black",
"behaviour.paintspray.blue.tooltip": "Can paint things in Blue",
Expand Down Expand Up @@ -2589,8 +2590,8 @@
"effect.gtceu.weak_poison": "Weak Poison",
"enchantment.damage.disjunction": "Disjunction",
"enchantment.disjunction": "Disjunction",
"enchantment.gtceu.disjunction.desc": "Applies Weakness and Slowness to Ender-related mobs.",
"enchantment.gtceu.hard_hammer.desc": "Breaks blocks as if they were mined with a GregTech Hammer.",
"enchantment.gtceu.disjunction.description": "Applies Weakness and Slowness to Ender-related mobs.",
"enchantment.gtceu.hard_hammer.description": "Breaks blocks as if they were mined with a GregTech Hammer.",
"enchantment.hard_hammer": "Hammering",
"entity.gtceu.boat": "Boat",
"entity.gtceu.chest_boat": "Chest Boat",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.context.UseOnContext;
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.TntBlock;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.fluids.capability.IFluidHandler;
Expand All @@ -36,11 +34,12 @@
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;

import java.awt.*;
import java.util.List;

import javax.annotation.Nullable;

import static net.minecraft.world.level.block.AbstractCandleBlock.LIT;

public class LighterBehavior implements IDurabilityBar, IInteractionItem, IAddInformation {

public static final String LIGHTER_OPEN = "lighterOpen";
Expand Down Expand Up @@ -88,34 +87,93 @@ public InteractionResult onItemUseFirst(ItemStack itemStack, UseOnContext contex
// ItemStack itemStack = player.getItemInHand(usedHand);
CompoundTag tag = itemStack.getOrCreateTag();
Player player = context.getPlayer();
if ((!canOpen || (tag.getBoolean(LIGHTER_OPEN)) && !player.isCrouching()) && consumeFuel(player, itemStack)) {
player.level().playSound(null, player.getOnPos(), SoundEvents.FLINTANDSTEEL_USE, SoundSource.PLAYERS, 1.0F,
GTValues.RNG.nextFloat() * 0.4F + 0.8F);
BlockState state = context.getLevel().getBlockState(context.getClickedPos());
Block block = state.getBlock();
if (block instanceof TntBlock tnt) {
tnt.onCaughtFire(null, context.getLevel(), context.getClickedPos(), null, player);
context.getLevel().setBlock(context.getClickedPos(), Blocks.AIR.defaultBlockState(),
BlockPos pos = context.getClickedPos();
BlockState state = context.getLevel().getBlockState(pos);
Block block = state.getBlock();
BlockPos offset = pos.offset(context.getClickedFace().getNormal());

if ((!canOpen || (tag.getBoolean(LIGHTER_OPEN)) && !player.isCrouching())) {
if (block instanceof TntBlock tnt && consumeFuel(player, itemStack)) {
tnt.onCaughtFire(null, context.getLevel(), pos, null, player);
context.getLevel().setBlock(pos, Blocks.AIR.defaultBlockState(),
Block.UPDATE_ALL_IMMEDIATE);
player.level().playSound(null, player.getOnPos(), SoundEvents.FLINTANDSTEEL_USE, SoundSource.PLAYERS,
1.0F,
GTValues.RNG.nextFloat() * 0.4F + 0.8F);
return InteractionResult.SUCCESS;
}
if (block instanceof GTExplosiveBlock explosive) {
explosive.explode(context.getLevel(), context.getClickedPos(), player);
context.getLevel().setBlock(context.getClickedPos(), Blocks.AIR.defaultBlockState(),
if (block instanceof GTExplosiveBlock explosive && consumeFuel(player, itemStack)) {
explosive.explode(context.getLevel(), pos, player);
context.getLevel().setBlock(pos, Blocks.AIR.defaultBlockState(),
Block.UPDATE_ALL_IMMEDIATE);
player.level().playSound(null, player.getOnPos(), SoundEvents.FLINTANDSTEEL_USE, SoundSource.PLAYERS,
1.0F,
GTValues.RNG.nextFloat() * 0.4F + 0.8F);
return InteractionResult.SUCCESS;
}
if (block instanceof CandleBlock) {
if (CandleBlock.canLight(state) && !CandleBlock.isLit(state) && consumeFuel(player, itemStack)) {
context.getLevel().setBlock(pos, state.setValue(LIT, true), Block.UPDATE_ALL_IMMEDIATE);
player.level().playSound(null, player.getOnPos(), SoundEvents.FLINTANDSTEEL_USE,
SoundSource.PLAYERS, 1.0F,
GTValues.RNG.nextFloat() * 0.4F + 0.8F);
return InteractionResult.SUCCESS;
} else return InteractionResult.PASS;
}
if (block instanceof CandleCakeBlock) {
if (CandleCakeBlock.canLight(state) && !CandleCakeBlock.isLit(state) &&
consumeFuel(player, itemStack)) {
context.getLevel().setBlock(pos, state.setValue(LIT, true), Block.UPDATE_ALL_IMMEDIATE);
player.level().playSound(null, player.getOnPos(), SoundEvents.FLINTANDSTEEL_USE,
SoundSource.PLAYERS, 1.0F,
GTValues.RNG.nextFloat() * 0.4F + 0.8F);
return InteractionResult.SUCCESS;
} else return InteractionResult.PASS;
}
if (block instanceof CampfireBlock) {
if (CampfireBlock.canLight(state) && !CampfireBlock.isLitCampfire(state) &&
consumeFuel(player, itemStack)) {
context.getLevel().setBlock(pos, state.setValue(LIT, true), Block.UPDATE_ALL_IMMEDIATE);
player.level().playSound(null, player.getOnPos(), SoundEvents.FLINTANDSTEEL_USE,
SoundSource.PLAYERS, 1.0F,
GTValues.RNG.nextFloat() * 0.4F + 0.8F);
return InteractionResult.SUCCESS;
} else return InteractionResult.PASS;
}
if (block instanceof SoulSandBlock && block != Blocks.SOUL_FIRE && consumeFuel(player, itemStack)) {
context.getLevel().setBlock(offset, Blocks.SOUL_FIRE.defaultBlockState(), Block.UPDATE_ALL_IMMEDIATE);
if (!context.getLevel().isClientSide) {
CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer) player, offset, itemStack);
}
player.level().playSound(null, player.getOnPos(), SoundEvents.FLINTANDSTEEL_USE, SoundSource.PLAYERS,
1.0F,
GTValues.RNG.nextFloat() * 0.4F + 0.8F);
return InteractionResult.PASS;
}
if (block == Blocks.SOUL_SOIL && block != Blocks.SOUL_FIRE && consumeFuel(player, itemStack)) {
context.getLevel().setBlock(offset, Blocks.SOUL_FIRE.defaultBlockState(), Block.UPDATE_ALL_IMMEDIATE);
if (!context.getLevel().isClientSide) {
CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer) player, offset, itemStack);
}
player.level().playSound(null, player.getOnPos(), SoundEvents.FLINTANDSTEEL_USE, SoundSource.PLAYERS,
1.0F,
GTValues.RNG.nextFloat() * 0.4F + 0.8F);
return InteractionResult.PASS;
}

BlockPos offset = context.getClickedPos().offset(context.getClickedFace().getNormal());
if (context.getLevel().isEmptyBlock(offset)) {
if (context.getLevel().isEmptyBlock(offset) &&
BaseFireBlock.canBePlacedAt(context.getLevel(), offset, context.getHorizontalDirection()) &&
block != Blocks.FIRE && block != Blocks.SOUL_FIRE && consumeFuel(player, itemStack)) {
context.getLevel().setBlock(offset, Blocks.FIRE.defaultBlockState(), Block.UPDATE_ALL_IMMEDIATE);
if (!context.getLevel().isClientSide) {
CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer) player, offset, itemStack);
}
player.level().playSound(null, player.getOnPos(), SoundEvents.FLINTANDSTEEL_USE, SoundSource.PLAYERS,
1.0F,
GTValues.RNG.nextFloat() * 0.4F + 0.8F);
return InteractionResult.SUCCESS;
}
return InteractionResult.PASS;
}

return InteractionResult.FAIL;
}

Expand Down Expand Up @@ -216,8 +274,9 @@ public boolean showEmptyBar(ItemStack itemStack) {
@Override
public void appendHoverText(ItemStack stack, @org.jetbrains.annotations.Nullable Level level,
List<Component> tooltipComponents, TooltipFlag isAdvanced) {
tooltipComponents.add(
Component.translatable(usesFluid ? "behaviour.lighter.fluid.tooltip" : "behaviour.lighter.tooltip"));
tooltipComponents.add(Component
.translatable(usesFluid ? "behaviour.lighter.fluid.tooltip" : "behaviour.lighter.tooltip.description"));
tooltipComponents.add(Component.translatable("behaviour.lighter.tooltip.usage"));
if (hasMultipleUses && !usesFluid) {
tooltipComponents.add(Component.translatable("behaviour.lighter.uses", getUsesLeft(stack)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,8 @@ public static void init(RegistrateLangProvider provider) {
provider.add("behaviour.soft_hammer", "Activates and Deactivates Machines");
provider.add("behaviour.soft_hammer.enabled", "Working Enabled");
provider.add("behaviour.soft_hammer.disabled", "Working Disabled");
provider.add("behaviour.lighter.tooltip", "Can light things on fire");
provider.add("behaviour.lighter.tooltip.description", "Can light things on fire");
provider.add("behaviour.lighter.tooltip.usage", "Shift-right click to open/close");
provider.add("behaviour.lighter.fluid.tooltip", "Can light things on fire with Butane or Propane");
provider.add("behaviour.lighter.uses", "Remaining uses: %d");
provider.add("behavior.toggle_energy_consumer.tooltip", "Use to toggle mode");
Expand All @@ -723,10 +724,10 @@ public static void init(RegistrateLangProvider provider) {
provider.add("behaviour.paintspray.uses", "Remaining Uses: %d");
provider.add("behaviour.prospecting", "Usable for Prospecting");
provider.add("enchantment.damage.disjunction", "Disjunction");
provider.add("enchantment.gtceu.disjunction.desc",
provider.add("enchantment.gtceu.disjunction.description",
"Applies Weakness and Slowness to Ender-related mobs.");
provider.add("enchantment.hard_hammer", "Hammering");
provider.add("enchantment.gtceu.hard_hammer.desc",
provider.add("enchantment.gtceu.hard_hammer.description",
"Breaks blocks as if they were mined with a GregTech Hammer.");
provider.add("tile.gtceu.seal.name", "Sealed Block");
provider.add("tile.gtceu.foam.name", "Foam");
Expand Down

0 comments on commit b312167

Please sign in to comment.