forked from Vatuu/tesseract
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
103 additions
and
17 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
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
36 changes: 36 additions & 0 deletions
36
src/main/java/dev/vatuu/tesseract/impl/cmd/ChangeDimensionCommand.java
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,36 @@ | ||
package dev.vatuu.tesseract.impl.cmd; | ||
|
||
import com.mojang.brigadier.CommandDispatcher; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
import net.fabricmc.fabric.api.dimension.v1.FabricDimensions; | ||
import net.minecraft.command.arguments.BlockPosArgumentType; | ||
import net.minecraft.command.arguments.DimensionArgumentType; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.server.command.CommandManager; | ||
import net.minecraft.server.command.ServerCommandSource; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.dimension.DimensionType; | ||
|
||
public class ChangeDimensionCommand { | ||
|
||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher){ | ||
dispatcher.register( | ||
CommandManager.literal("changeDimension") | ||
.requires(src -> src.hasPermissionLevel(4)) | ||
.executes(ctx -> activate(ctx, DimensionType.OVERWORLD, new BlockPos(0, 64, 0))) | ||
.then(CommandManager.argument("dim", DimensionArgumentType.dimension()) | ||
.executes(ctx -> activate(ctx, DimensionArgumentType.getDimensionArgument(ctx, "dim"), new BlockPos(0, 64, 0))) | ||
.then(CommandManager.argument("pos", BlockPosArgumentType.blockPos()) | ||
.executes(ctx -> activate(ctx, DimensionArgumentType.getDimensionArgument(ctx, "dim"),BlockPosArgumentType.getBlockPos(ctx, "pos"))) | ||
) | ||
)); | ||
} | ||
|
||
private static int activate(CommandContext<ServerCommandSource> context, DimensionType type, BlockPos pos) throws CommandSyntaxException { | ||
PlayerEntity entity = context.getSource().getPlayer(); | ||
FabricDimensions.teleport(entity, type); | ||
entity.teleport(pos.getX(), pos.getY(), pos.getZ()); | ||
return 0; | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
src/main/java/dev/vatuu/tesseract/impl/extensions/mixins/BeeEntityMixin.java
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,30 @@ | ||
package dev.vatuu.tesseract.impl.extensions.mixins; | ||
|
||
import dev.vatuu.tesseract.impl.world.TesseractDimension; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.damage.DamageSource; | ||
import net.minecraft.entity.damage.EntityDamageSource; | ||
import net.minecraft.entity.passive.AnimalEntity; | ||
import net.minecraft.entity.passive.BeeEntity; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.explosion.Explosion; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(BeeEntity.class) | ||
public abstract class BeeEntityMixin extends AnimalEntity { | ||
|
||
public BeeEntityMixin(EntityType<? extends AnimalEntity> type, World world){ | ||
super(type, world); | ||
} | ||
|
||
@Inject(method = "damage", at = @At(value = "RETURN")) | ||
public void damage(DamageSource src, float amount, CallbackInfoReturnable info){ | ||
if(amount > 0 && src instanceof EntityDamageSource) | ||
if(((TesseractDimension)this.getEntityWorld().dimension).getSettings().isBeesExplode()) | ||
this.kill(); | ||
this.getEntityWorld().createExplosion(this, this.getPos().x, this.getPos().y, this.getPos().z, 2.3F, true, Explosion.DestructionType.BREAK); | ||
} | ||
} |
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
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
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