Improve Teleportation Restrictor
This commit is contained in:
parent
6f096b46cf
commit
60db4606d2
@ -1,5 +1,8 @@
|
||||
# Changelog
|
||||
|
||||
**1.0.25**
|
||||
* Improve Teleportation Restrictor
|
||||
|
||||
**1.0.24**
|
||||
* Fix Teleportation Restrictor only affecting living entities
|
||||
|
||||
|
@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
|
||||
fabric_loader_version = 0.7.10+build.191
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0.24
|
||||
mod_version = 1.0.25
|
||||
maven_group = com.thebrokenrail
|
||||
archives_base_name = reliccraft
|
||||
|
||||
|
@ -124,7 +124,7 @@ public abstract class AbstractDragonEggHolderBlock extends Block implements Bloc
|
||||
return Container.calculateComparatorOutput(world.getBlockEntity(pos));
|
||||
}
|
||||
|
||||
public abstract void tick(World world, BlockPos pos, Inventory inventory);
|
||||
public abstract void tick(World world, BlockPos pos);
|
||||
|
||||
public abstract void grantAdvancement(PlayerEntity player);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.thebrokenrail.reliccraft.block;
|
||||
|
||||
import com.thebrokenrail.reliccraft.RelicCraft;
|
||||
import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
@ -13,6 +14,8 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Tickable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class DragonEggHolderBlockEntity extends BlockEntity implements Inventory, Tickable {
|
||||
public DragonEggHolderBlockEntity() {
|
||||
super(RelicCraft.DRAGON_EGG_HOLDER_BLOCK_ENTITY);
|
||||
@ -95,7 +98,7 @@ public class DragonEggHolderBlockEntity extends BlockEntity implements Inventory
|
||||
assert getWorld() != null;
|
||||
Block block = getWorld().getBlockState(getPos()).getBlock();
|
||||
if (block instanceof AbstractDragonEggHolderBlock) {
|
||||
((AbstractDragonEggHolderBlock) block).tick(getWorld(), getPos(), this);
|
||||
((AbstractDragonEggHolderBlock) block).tick(getWorld(), getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,8 +111,10 @@ public class DragonEggHolderBlockEntity extends BlockEntity implements Inventory
|
||||
@Override
|
||||
public void markDirty() {
|
||||
super.markDirty();
|
||||
if (hasWorld() && !Objects.requireNonNull(getWorld()).isClient()) {
|
||||
updateBlockState();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBlockState() {
|
||||
if (hasWorld()) {
|
||||
|
@ -17,7 +17,7 @@ public class TeleportationBeaconBlock extends AbstractDragonEggHolderBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(World world, BlockPos pos, Inventory inventory) {
|
||||
public void tick(World world, BlockPos pos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,11 +2,11 @@ package com.thebrokenrail.reliccraft.block;
|
||||
|
||||
import com.thebrokenrail.reliccraft.RelicCraft;
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
@ -26,10 +26,11 @@ public class TeleportationRestrictorBlock extends AbstractDragonEggHolderBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(World world, BlockPos pos, Inventory inventory) {
|
||||
int radius = !inventory.getInvStack(0).isEmpty() ? 128 : 0;
|
||||
public void tick(World world, BlockPos pos) {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
int radius = state.get(ACTIVE) ? 128 : 0;
|
||||
Box box = new Box(pos).expand(radius);
|
||||
List<Entity> list = world.getNonSpectatingEntities(Entity.class, box);
|
||||
List<Entity> list = world.getEntities(Entity.class, box, null);
|
||||
for (Entity entity : list) {
|
||||
((TeleportingEntity) entity).resetTeleportCooldown();
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class MixinEntity implements TeleportationRestrictorBlock.TeleportingEnti
|
||||
|
||||
@Override
|
||||
public void resetTeleportCooldown() {
|
||||
teleportCooldown = 5;
|
||||
teleportCooldown = 4;
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "tick")
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.thebrokenrail.reliccraft.mixin;
|
||||
|
||||
import com.thebrokenrail.reliccraft.block.TeleportationRestrictorBlock;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.thrown.ThrownEnderpearlEntity;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -14,8 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
public class MixinThrownEnderpearlEntity {
|
||||
@Inject(at = @At("HEAD"), method = "onCollision", cancellable = true)
|
||||
public void onCollision(HitResult hitResult, CallbackInfo info) {
|
||||
LivingEntity owner = ((ThrownEnderpearlEntity) (Object) this).getOwner();
|
||||
if (owner != null && ((TeleportationRestrictorBlock.TeleportingEntity) owner).cannotTeleport()) {
|
||||
if (((TeleportationRestrictorBlock.TeleportingEntity) this).cannotTeleport()) {
|
||||
((ThrownEnderpearlEntity) (Object) this).remove();
|
||||
info.cancel();
|
||||
}
|
||||
|
Reference in New Issue
Block a user