2020-07-13 20:37:21 +00:00
|
|
|
package com.thebrokenrail.energonrelics.mixin;
|
|
|
|
|
2020-07-28 21:45:42 +00:00
|
|
|
import com.thebrokenrail.energonrelics.block.forcefield.util.AbstractFieldBlock;
|
2020-07-24 17:25:50 +00:00
|
|
|
import com.thebrokenrail.energonrelics.energy.core.util.EnergyTicker;
|
2020-07-28 21:45:42 +00:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
2020-07-13 20:37:21 +00:00
|
|
|
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;
|
2020-07-28 21:45:42 +00:00
|
|
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
2020-07-13 20:37:21 +00:00
|
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
|
|
|
|
|
|
@Mixin(World.class)
|
|
|
|
public abstract class MixinWorld {
|
|
|
|
@Shadow
|
|
|
|
public abstract boolean isClient();
|
|
|
|
|
|
|
|
@Inject(at = @At("TAIL"), method = "tickBlockEntities")
|
|
|
|
public void tickBlockEntities(CallbackInfo info) {
|
|
|
|
if (!isClient()) {
|
2020-07-26 00:09:03 +00:00
|
|
|
EnergyTicker.tick((World) (Object) this);
|
2020-07-13 20:37:21 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-28 21:45:42 +00:00
|
|
|
|
|
|
|
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;syncWorldEvent(ILnet/minecraft/util/math/BlockPos;I)V"), method = "breakBlock")
|
|
|
|
public void breakBlock(World world, int eventId, BlockPos pos, int data) {
|
|
|
|
if (!(Block.getStateFromRawId(data).getBlock() instanceof AbstractFieldBlock)) {
|
|
|
|
world.syncWorldEvent(eventId, pos, data);
|
|
|
|
}
|
|
|
|
}
|
2020-07-13 20:37:21 +00:00
|
|
|
}
|