Skip to content

Commit

Permalink
Change TorchEntity behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
noriokun4649 committed Jan 14, 2024
1 parent de7af91 commit 3ab6d26
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Change TorchEntity behavior
- Add German language
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ mod_name=TorchBowMod
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT License
# The mod version. See https://semver.org/
mod_version=1.0.0
mod_version=1.1.0
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand Down
34 changes: 33 additions & 1 deletion src/main/java/mod/torchbowmod/EntityTorch.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import net.minecraft.core.Direction;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LightningBolt;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.monster.Creeper;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
Expand All @@ -22,6 +24,7 @@
import static mod.torchbowmod.TorchBowMod.entityTorch;
import static net.minecraft.core.Direction.DOWN;
import static net.minecraft.core.Direction.UP;
import static net.minecraft.world.entity.EntityType.LIGHTNING_BOLT;
import static net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING;

public class EntityTorch extends AbstractArrow {
Expand All @@ -42,6 +45,9 @@ public EntityTorch(EntityType<EntityTorch> entityTorchEntityType, Level level) {
protected void onHitEntity(EntityHitResult entityRayTraceResult) {
super.onHitEntity(entityRayTraceResult);
Entity entity = entityRayTraceResult.getEntity();
if (entity instanceof Creeper creeper){
creeperIgnite(creeper);
}
entity.setRemainingFireTicks(100);
}

Expand All @@ -50,10 +56,36 @@ protected void onHitBlock(BlockHitResult raytraceResultIn) {
super.onHitBlock(raytraceResultIn);
HitResult.Type raytraceresult$type = raytraceResultIn.getType();
if (raytraceresult$type == HitResult.Type.BLOCK) {
setTorch(raytraceResultIn, raytraceResultIn);
var statePos = raytraceResultIn.getBlockPos();
if (level().getBlockState(statePos).getBlock() == Blocks.TNT){
tntIgnite(raytraceResultIn);
}else {
setTorch(raytraceResultIn, raytraceResultIn);
}
}
}

private void creeperIgnite(Creeper creeper){
if (Math.random() < 0.05) {
creeper.ignite();
var bolt = new LightningBolt(LIGHTNING_BOLT, level());
bolt.setPos(creeper.getOnPos().getCenter());
level().addFreshEntity(bolt);
} else if (Math.random() < 0.3) {
creeper.ignite();
}
}

private void tntIgnite(BlockHitResult blockHitResult){
var world = level();
var blockPos = blockHitResult.getBlockPos();
var blockState = world.getBlockState(blockPos);
var block = blockState.getBlock();
block.onCaughtFire(blockState,world,blockPos,null,null);
world.removeBlock(blockPos, false);
this.remove(RemovalReason.KILLED);
}

private void setTorch(BlockHitResult blockraytraceresult, HitResult raytraceResultIn) {
BlockPos blockpos = blockraytraceresult.getBlockPos();
if (!this.level().getBlockState(blockpos).isAir()) {
Expand Down
15 changes: 15 additions & 0 deletions src/main/resources/assets/torchbowmod/lang/de_de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"item.torchbowmod.torchbow": "Fackelbogen",
"item.torchbowmod.multitorch": "Fackelbund",
"item.torchbowmod.torcharrow": "Fackelpfeil",
"itemGroup.torchbowmod.torchbowmod_tab": "Fackelbogenseite",
"death.attack.EntityTorch": "%1$s starb durch %2$s's Fackel.",
"log.sb.check": "Storagebox Introduction Status check now......",
"log.sb.load": "Storagebox confirmed the introduction. Load complete.",
"log.sb.error": "Storagebox Load Error.",
"log.sb.unload": "Storagebox Non-Introduction.",
"log.sg.check": "Silent's Gems Introduction Status check now.......",
"log.sg.load": "Silent's Gemsconfirmed the introduction. Load complete.",
"log.sg.error": "Silent's Gems Load Error.",
"log.sg.unload": "Silent's Gems Non-Introduction."
}

0 comments on commit 3ab6d26

Please sign in to comment.