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