Fix Bug
This commit is contained in:
parent
99f085f3bc
commit
9fd946ae9a
@ -1,4 +1,7 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
**1.0.1**
|
||||||
|
* Fix Bug
|
||||||
|
|
||||||
**1.0**
|
**1.0**
|
||||||
* Initial Release
|
* Initial Release
|
@ -1,13 +1,15 @@
|
|||||||
# Done to increase the memory available to gradle.
|
# Done to increase the memory available to gradle.
|
||||||
org.gradle.jvmargs=-Xmx1G
|
org.gradle.jvmargs=-Xmx1G
|
||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/use
|
# check these on https://fabricmc.net/use
|
||||||
minecraft_version=20w11a
|
minecraft_version = 20w11a
|
||||||
curseforge_id=367307
|
curseforge_id = 367307
|
||||||
simple_minecraft_version=1.16-Snapshot
|
simple_minecraft_version = 1.16-Snapshot
|
||||||
yarn_mappings=20w11a+build.6
|
yarn_mappings = 20w11a+build.6
|
||||||
loader_version=0.7.8+build.184
|
loader_version = 0.7.8+build.184
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.0.0
|
mod_version = 1.0.1
|
||||||
maven_group=com.thebrokenrail
|
maven_group = com.thebrokenrail
|
||||||
archives_base_name=obsidianspawn
|
archives_base_name = obsidianspawn
|
||||||
|
@ -2,7 +2,7 @@ package com.thebrokenrail.obsidianspawn;
|
|||||||
|
|
||||||
import net.minecraft.world.dimension.DimensionType;
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
|
|
||||||
public interface DataHolder {
|
public interface SpawnDataHolder {
|
||||||
void setSpawnDimension(DimensionType dimension);
|
void setSpawnDimension(DimensionType dimension);
|
||||||
|
|
||||||
DimensionType getSpawnDimension();
|
DimensionType getSpawnDimension();
|
@ -1,8 +1,10 @@
|
|||||||
package com.thebrokenrail.obsidianspawn.mixin;
|
package com.thebrokenrail.obsidianspawn.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.CryingObsidianBlock;
|
import net.minecraft.block.CryingObsidianBlock;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
@ -10,12 +12,17 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings({"unused", "deprecation"})
|
||||||
@Mixin(CryingObsidianBlock.class)
|
@Mixin(CryingObsidianBlock.class)
|
||||||
public class MixinCryingObsidianBlock {
|
public abstract class MixinCryingObsidianBlock extends Block {
|
||||||
|
public MixinCryingObsidianBlock(Settings settings) {
|
||||||
|
super(settings);
|
||||||
|
}
|
||||||
|
|
||||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||||
if (!world.isClient()) {
|
if (!world.isClient()) {
|
||||||
player.setPlayerSpawn(pos, false, true);
|
player.setPlayerSpawn(pos, false, false);
|
||||||
|
player.sendMessage(new TranslatableText("block.minecraft.bed.set_spawn"));
|
||||||
}
|
}
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.thebrokenrail.obsidianspawn.mixin;
|
package com.thebrokenrail.obsidianspawn.mixin;
|
||||||
|
|
||||||
import com.thebrokenrail.obsidianspawn.DataHolder;
|
|
||||||
import com.thebrokenrail.obsidianspawn.ObsidianSpawn;
|
import com.thebrokenrail.obsidianspawn.ObsidianSpawn;
|
||||||
|
import com.thebrokenrail.obsidianspawn.SpawnDataHolder;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.CryingObsidianBlock;
|
import net.minecraft.block.CryingObsidianBlock;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
@ -20,7 +20,7 @@ import java.util.Optional;
|
|||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Mixin(PlayerEntity.class)
|
@Mixin(PlayerEntity.class)
|
||||||
public class MixinPlayerEntity implements DataHolder {
|
public class MixinPlayerEntity implements SpawnDataHolder {
|
||||||
private DimensionType spawnDimension = DimensionType.OVERWORLD;
|
private DimensionType spawnDimension = DimensionType.OVERWORLD;
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "readCustomDataFromTag")
|
@Inject(at = @At("HEAD"), method = "readCustomDataFromTag")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.thebrokenrail.obsidianspawn.mixin;
|
package com.thebrokenrail.obsidianspawn.mixin;
|
||||||
|
|
||||||
import com.thebrokenrail.obsidianspawn.DataHolder;
|
|
||||||
import com.thebrokenrail.obsidianspawn.ObsidianSpawn;
|
import com.thebrokenrail.obsidianspawn.ObsidianSpawn;
|
||||||
|
import com.thebrokenrail.obsidianspawn.SpawnDataHolder;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.CryingObsidianBlock;
|
import net.minecraft.block.CryingObsidianBlock;
|
||||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||||
@ -18,7 +18,7 @@ public class MixinServerPlayNetworkHandler {
|
|||||||
@ModifyArg(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/PlayerManager;respawnPlayer(Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/world/dimension/DimensionType;Z)Lnet/minecraft/server/network/ServerPlayerEntity;"), method = "onClientStatus", index = 1)
|
@ModifyArg(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/PlayerManager;respawnPlayer(Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/world/dimension/DimensionType;Z)Lnet/minecraft/server/network/ServerPlayerEntity;"), method = "onClientStatus", index = 1)
|
||||||
public DimensionType adjustRespawnDimension(ServerPlayerEntity player, DimensionType dimension, boolean alive) {
|
public DimensionType adjustRespawnDimension(ServerPlayerEntity player, DimensionType dimension, boolean alive) {
|
||||||
if (player.getSpawnPosition() != null) {
|
if (player.getSpawnPosition() != null) {
|
||||||
DimensionType type = ((DataHolder) player).getSpawnDimension();
|
DimensionType type = ((SpawnDataHolder) player).getSpawnDimension();
|
||||||
WorldView world = player.server.getWorld(type);
|
WorldView world = player.server.getWorld(type);
|
||||||
Block block = world.getBlockState(player.getSpawnPosition()).getBlock();
|
Block block = world.getBlockState(player.getSpawnPosition()).getBlock();
|
||||||
if (!(block instanceof CryingObsidianBlock)) {
|
if (!(block instanceof CryingObsidianBlock)) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.thebrokenrail.obsidianspawn.mixin;
|
package com.thebrokenrail.obsidianspawn.mixin;
|
||||||
|
|
||||||
import com.thebrokenrail.obsidianspawn.DataHolder;
|
import com.thebrokenrail.obsidianspawn.SpawnDataHolder;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@ -9,11 +9,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Mixin(ServerPlayerEntity.class)
|
@Mixin(ServerPlayerEntity.class)
|
||||||
public abstract class MixinServerPlayerEntity implements DataHolder {
|
public abstract class MixinServerPlayerEntity implements SpawnDataHolder {
|
||||||
@Inject(at = @At("HEAD"), method = "copyFrom")
|
@Inject(at = @At("HEAD"), method = "copyFrom")
|
||||||
public void copyFrom(ServerPlayerEntity oldPlayer, boolean alive, CallbackInfo info) {
|
public void copyFrom(ServerPlayerEntity oldPlayer, boolean alive, CallbackInfo info) {
|
||||||
DataHolder oldData = (DataHolder) oldPlayer;
|
SpawnDataHolder oldData = (SpawnDataHolder) oldPlayer;
|
||||||
DataHolder newData = this;
|
SpawnDataHolder newData = this;
|
||||||
|
|
||||||
newData.setSpawnDimension(oldData.getSpawnDimension());
|
newData.setSpawnDimension(oldData.getSpawnDimension());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user