-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
primed pipe bombs now explode when dropped
- Loading branch information
1 parent
4840728
commit 112d834
Showing
3 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package ladysnake.blast.mixin; | ||
|
||
import ladysnake.blast.common.entity.PipeBombEntity; | ||
import ladysnake.blast.common.init.BlastComponentTypes; | ||
import ladysnake.blast.common.init.BlastEntities; | ||
import ladysnake.blast.common.init.BlastItems; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.ItemEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ItemEntity.class) | ||
public abstract class ItemEntityMixin extends Entity { | ||
@Shadow | ||
public abstract ItemStack getStack(); | ||
|
||
public ItemEntityMixin(EntityType<?> type, World world) { | ||
super(type, world); | ||
} | ||
|
||
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;tick()V"), cancellable = true) | ||
private void blast$pipeBomb(CallbackInfo ci) { | ||
if (getStack().isOf(BlastItems.PIPE_BOMB) && getStack().getOrDefault(BlastComponentTypes.PRIMED, false)) { | ||
while (!getStack().isEmpty()) { | ||
PipeBombEntity pipeBomb = BlastEntities.PIPE_BOMB.create(getWorld()); | ||
pipeBomb.setPosition(getPos()); | ||
pipeBomb.setVelocity(getVelocity()); | ||
pipeBomb.setItem(getStack().copyWithCount(1)); | ||
getWorld().spawnEntity(pipeBomb); | ||
getStack().decrement(1); | ||
} | ||
discard(); | ||
ci.cancel(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters