Merge mixins, cleanup code.

This commit is contained in:
IzzelAliz 2020-08-17 23:05:28 +08:00
parent c63e2a4952
commit 609c15c0fe
130 changed files with 1479 additions and 2259 deletions

View File

@ -52,6 +52,4 @@ public interface EntityBridge extends ICommandSourceBridge {
void bridge$setRideCooldown(int rideCooldown);
int bridge$getRideCooldown();
double bridge$getEyeHeight();
}

View File

@ -1,6 +1,5 @@
package io.izzel.arclight.common.bridge.entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import org.bukkit.craftbukkit.v.entity.CraftLivingEntity;
@ -21,10 +20,6 @@ public interface LivingEntityBridge extends EntityBridge {
int bridge$getExpToDrop();
void bridge$dropExperience();
void bridge$createWitherRose(LivingEntity entity);
void bridge$pushHealReason(EntityRegainHealthEvent.RegainReason regainReason);
void bridge$heal(float healAmount, EntityRegainHealthEvent.RegainReason regainReason);

View File

@ -1,11 +0,0 @@
package io.izzel.arclight.common.bridge.item;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.world.World;
public interface BlockItemBridge {
boolean bridge$noCollisionInSel(World world, BlockState state, BlockPos pos, ISelectionContext context);
}

View File

@ -1,10 +1,5 @@
package io.izzel.arclight.common.bridge.network.play;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.nbt.StringNBT;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.Location;
import org.bukkit.event.player.PlayerTeleportEvent;
@ -17,12 +12,6 @@ public interface ServerPlayNetHandlerBridge {
void bridge$teleport(Location dest);
boolean bridge$worldNoCollision(ServerWorld world, Entity entity, AxisAlignedBB aabb);
StringNBT bridge$stringNbt(String s);
void bridge$dropItems(ServerPlayerEntity player, boolean all);
boolean bridge$processedDisconnect();
boolean bridge$isDisconnected();

View File

@ -1,10 +1,5 @@
package io.izzel.arclight.common.bridge.server.management;
import net.minecraft.block.BlockState;
import net.minecraft.network.play.client.CPlayerDiggingPacket;
import net.minecraft.network.play.server.SPlayerDiggingPacket;
import net.minecraft.util.math.BlockPos;
public interface PlayerInteractionManagerBridge {
boolean bridge$isFiredInteract();
@ -14,8 +9,4 @@ public interface PlayerInteractionManagerBridge {
boolean bridge$getInteractResult();
void bridge$setInteractResult(boolean b);
SPlayerDiggingPacket bridge$diggingPacket(BlockPos pos, BlockState state, CPlayerDiggingPacket.Action action, boolean successful, String context);
void bridge$creativeHarvestBlock(BlockPos pos, CPlayerDiggingPacket.Action action, String context);
}

View File

@ -1,14 +1,7 @@
package io.izzel.arclight.common.bridge.server.management;
import net.minecraft.entity.Entity;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.network.play.server.SRespawnPacket;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.GameType;
import net.minecraft.world.WorldType;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.network.login.ServerLoginNetHandler;
import org.bukkit.craftbukkit.v.CraftServer;
@ -24,10 +17,4 @@ public interface PlayerListBridge {
CraftServer bridge$getCraftServer();
ServerPlayerEntity bridge$canPlayerLogin(SocketAddress socketAddress, GameProfile gameProfile, ServerLoginNetHandler handler);
boolean bridge$worldNoCollision(ServerWorld world, Entity entity);
void bridge$setSpawnPoint(ServerPlayerEntity player, BlockPos pos, boolean flag, DimensionType type, boolean flag1);
SRespawnPacket bridge$respawnPacket(DimensionType type, long seed, WorldType worldType, GameType gameType);
}

View File

@ -14,6 +14,4 @@ public interface ExplosionBridge {
Explosion.Mode bridge$getMode();
boolean bridge$wasCancelled();
float bridge$callBlockExplodeEvent();
}

View File

@ -1,9 +1,5 @@
package io.izzel.arclight.common.bridge.world.server;
import net.minecraft.entity.EntityClassification;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.server.ServerWorldLightManager;
import java.io.IOException;
@ -19,6 +15,4 @@ public interface ServerChunkProviderBridge {
boolean bridge$isChunkLoaded(int x, int z);
ServerWorldLightManager bridge$getLightManager();
void bridge$worldNaturalSpawn(EntityClassification classification, World worldIn, Chunk chunk, BlockPos pos);
}

View File

@ -1,15 +1,8 @@
package io.izzel.arclight.common.bridge.world.storage;
import net.minecraft.world.World;
import net.minecraft.world.dimension.Dimension;
import net.minecraft.world.dimension.DimensionType;
import org.bukkit.craftbukkit.v.map.CraftMapView;
import java.util.function.BiFunction;
public interface MapDataBridge {
CraftMapView bridge$getMapView();
DimensionType bridge$dimension(int id, String suffix, String dir, BiFunction<World, DimensionType, ? extends Dimension> provider, boolean skyLight);
}

View File

@ -73,12 +73,8 @@ public abstract class JavaPluginLoaderMixin implements JavaPluginLoaderBridge {
Method[] publicMethods = listener.getClass().getMethods();
Method[] privateMethods = listener.getClass().getDeclaredMethods();
methods = new HashSet<>(publicMethods.length + privateMethods.length, 1.0f);
for (Method method : publicMethods) {
methods.add(method);
}
for (Method method : privateMethods) {
methods.add(method);
}
methods.addAll(Arrays.asList(publicMethods));
methods.addAll(Arrays.asList(privateMethods));
} catch (NoClassDefFoundError e) {
plugin.getLogger().severe("Plugin " + plugin.getDescription().getFullName() + " has failed to register events for " + listener.getClass() + " because " + e.getMessage() + " does not exist.");
return ret;

View File

@ -4,9 +4,13 @@ import io.izzel.arclight.common.bridge.entity.EntityBridge;
import net.minecraft.block.AbstractButtonBlock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.state.BooleanProperty;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v.block.CraftBlock;
@ -18,9 +22,11 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import java.util.List;
import java.util.Random;
@Mixin(AbstractButtonBlock.class)
public class AbstractButtonBlockMixin {
@ -71,4 +77,33 @@ public class AbstractButtonBlockMixin {
ci.cancel();
}
}
@Inject(method = "onBlockActivated", cancellable = true, at = @At(value = "HEAD"))
public void arclight$blockRedstone1(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit, CallbackInfoReturnable<Boolean> cir) {
if (!state.get(POWERED)) {
boolean powered = state.get(POWERED);
Block block = CraftBlock.at(worldIn, pos);
int old = (powered) ? 15 : 0;
int current = (!powered) ? 15 : 0;
BlockRedstoneEvent event = new BlockRedstoneEvent(block, old, current);
Bukkit.getPluginManager().callEvent(event);
if ((event.getNewCurrent() > 0) == (powered)) {
cir.setReturnValue(true);
}
}
}
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private void arclight$blockRedstone2(BlockState state, ServerWorld worldIn, BlockPos pos, Random rand, CallbackInfo ci) {
Block block = CraftBlock.at(worldIn, pos);
BlockRedstoneEvent event = new BlockRedstoneEvent(block, 15, 0);
Bukkit.getPluginManager().callEvent(event);
if (event.getNewCurrent() > 0) {
ci.cancel();
}
}
}

View File

@ -5,11 +5,13 @@ import net.minecraft.block.CactusBlock;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(CactusBlock.class)
@ -24,4 +26,9 @@ public class CactusBlockMixin {
private void arclight$cactusDamage2(BlockState state, World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) {
CraftEventFactory.blockDamage = null;
}
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
private boolean arclight$blockGrow(ServerWorld serverWorld, BlockPos pos, BlockState state) {
return CraftEventFactory.handleBlockGrowEvent(serverWorld, pos, state);
}
}

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import net.minecraft.block.BlockState;
@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(CakeBlock.class)
public class CakeBlockMixin_1_15 {
public class CakeBlockMixin {
@Redirect(method = "func_226911_a_", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/FoodStats;addStats(IF)V"))
private void arclight$eatCake(FoodStats foodStats, int foodLevelIn, float foodSaturationModifier, IWorld worldIn, BlockPos pos, BlockState state, PlayerEntity player) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import net.minecraft.block.BlockState;
@ -26,7 +26,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(CauldronBlock.class)
public class CauldronBlockMixin_1_15 {
public class CauldronBlockMixin {
@Inject(method = "onEntityCollision", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;extinguish()V"))
public void arclight$extinguish(BlockState state, World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.mod.util.ChestBlockDoubleInventoryHacks;
import net.minecraft.inventory.DoubleSidedInventory;
@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.Overwrite;
import java.util.Optional;
@Mixin(targets = "net/minecraft/block/ChestBlock$2")
public class ChestBlock2Mixin_1_15 {
public class ChestBlock2Mixin {
/**
* @author IzzelAliz

View File

@ -1,6 +1,5 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.mixin.core.block.BlockMixin;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -23,7 +22,7 @@ import javax.annotation.Nullable;
import java.util.Random;
@Mixin(ChorusFlowerBlock.class)
public abstract class ChorusFlowerBlockMixin_1_15 extends BlockMixin {
public abstract class ChorusFlowerBlockMixin extends BlockMixin {
// @formatter:off
@Shadow @Final public static IntegerProperty AGE;
@ -74,7 +73,7 @@ public abstract class ChorusFlowerBlockMixin_1_15 extends BlockMixin {
flag = true;
}
if (flag && areAllNeighborsEmpty(worldIn, blockpos, (Direction) null) && worldIn.isAirBlock(pos.up(2))) {
if (flag && areAllNeighborsEmpty(worldIn, blockpos, null) && worldIn.isAirBlock(pos.up(2))) {
if (CraftEventFactory.handleBlockSpreadEvent(worldIn, pos, pos.up(), state.with(ChorusFlowerBlock.AGE, i), 2)) {
worldIn.setBlockState(pos, this.plantBlock.makeConnections(worldIn, pos), 2);
this.placeGrownFlower(worldIn, blockpos, i);

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CocoaBlock;
@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(CocoaBlock.class)
public class CocoaBlockMixin_1_15 {
public class CocoaBlockMixin {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$blockGrow(ServerWorld world, BlockPos pos, BlockState newState, int flags) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Random;
@Mixin(CoralBlock.class)
public class CoralBlockMixin_1_15 {
public class CoralBlockMixin {
// @formatter:off
@Shadow @Final private Block deadBlock;

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.AbstractCoralPlantBlock;
import net.minecraft.block.Block;
@ -17,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Random;
@Mixin(CoralFinBlock.class)
public class CoralFinBlockMixin_1_15 {
public class CoralFinBlockMixin {
// @formatter:off
@Shadow @Final private Block deadBlock;

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.AbstractCoralPlantBlock;
import net.minecraft.block.Block;
@ -17,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Random;
@Mixin(CoralPlantBlock.class)
public class CoralPlantBlockMixin_1_15 {
public class CoralPlantBlockMixin {
// @formatter:off
@Shadow @Final private Block deadBlock;

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.AbstractCoralPlantBlock;
import net.minecraft.block.Block;
@ -18,7 +18,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Random;
@Mixin(CoralWallFanBlock.class)
public class CoralWallFanBlockMixin_1_15 {
public class CoralWallFanBlockMixin {
// @formatter:off
@Shadow @Final private Block deadBlock;

View File

@ -5,6 +5,7 @@ import net.minecraft.block.CropsBlock;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.event.ForgeEventFactory;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.EntityChangeBlockEvent;
@ -27,4 +28,9 @@ public class CropsBlockMixin {
EntityChangeBlockEvent event = CraftEventFactory.callEntityChangeBlockEvent(entity, pos, state, result);
return event.isCancelled();
}
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$blockGrowTick(ServerWorld world, BlockPos pos, BlockState newState, int flags) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags);
}
}

View File

@ -5,10 +5,12 @@ import net.minecraft.block.Blocks;
import net.minecraft.block.FarmlandBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(FarmlandBlock.class)
@ -20,4 +22,9 @@ public abstract class FarmlandBlockMixin extends BlockMixin {
ci.cancel();
}
}
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$moistureChange(ServerWorld world, BlockPos pos, BlockState newState, int flags) {
return CraftEventFactory.handleMoistureChangeEvent(world, pos, newState, flags);
}
}

View File

@ -10,6 +10,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v.block.CraftBlock;
@ -35,6 +36,25 @@ public abstract class FireBlockMixin implements FireBlockBridge {
@Shadow @Final private Object2IntMap<net.minecraft.block.Block> flammabilities;
// @formatter:on
@Redirect(method = "tick", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$fireSpread(ServerWorld world, BlockPos mutablePos, BlockState newState, int flags,
BlockState state, ServerWorld worldIn, BlockPos pos) {
if (world.getBlockState(mutablePos).getBlock() != Blocks.FIRE) {
if (!CraftEventFactory.callBlockIgniteEvent(world, mutablePos, pos).isCancelled()) {
return CraftEventFactory.handleBlockSpreadEvent(world, pos, mutablePos, newState, flags);
}
}
return false;
}
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;removeBlock(Lnet/minecraft/util/math/BlockPos;Z)Z"))
public boolean arclight$extinguish1(ServerWorld world, BlockPos pos, boolean isMoving) {
if (!CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.AIR.getDefaultState()).isCancelled()) {
world.removeBlock(pos, isMoving);
}
return false;
}
@Inject(method = "tryCatchFire", cancellable = true, at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;"))
public void arclight$blockBurn(World worldIn, BlockPos pos, int chance, Random random, int age, Direction face, CallbackInfo ci) {
Block theBlock = CraftBlock.at(worldIn, pos);

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.GrassBlock;
@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(GrassBlock.class)
public class GrassBlockMixin_1_15 {
public class GrassBlockMixin {
@Redirect(method = "grow", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$blockGrow(ServerWorld world, BlockPos pos, BlockState newState, int flags) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.KelpTopBlock;
@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(KelpTopBlock.class)
public class KelpTopBlockMixin_1_15 {
public class KelpTopBlockMixin {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
public boolean arclight$blockGrow(ServerWorld world, BlockPos pos, BlockState state) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.LeavesBlock;
@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Random;
@Mixin(LeavesBlock.class)
public class LeavesBlockMixin_1_15 {
public class LeavesBlockMixin {
@Inject(method = "randomTick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/block/LeavesBlock;spawnDrops(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)V"))
public void arclight$leavesDecay(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.LeverBlock;
@ -20,7 +20,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(LeverBlock.class)
public class LeverBlockMixin_1_15 {
public class LeverBlockMixin {
// @formatter:off
@Shadow @Final public static BooleanProperty POWERED;

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LilyPadBlock.class)
public class LilyPadBlockMixin_1_15 {
public class LilyPadBlockMixin {
@Inject(method = "onEntityCollision", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;destroyBlock(Lnet/minecraft/util/math/BlockPos;ZLnet/minecraft/entity/Entity;)Z"))
public void arclight$entityChangeBlock(BlockState state, World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.MushroomBlock;
@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(MushroomBlock.class)
public class MushroomBlockMixin_1_15 {
public class MushroomBlockMixin {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$blockSpread(ServerWorld world, BlockPos toPos, BlockState newState, int flags, BlockState state, ServerWorld worldIn, BlockPos fromPos) {

View File

@ -2,19 +2,27 @@ package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.bridge.block.NetherPortalBlockBridge;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.entity.EntityTypeBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import net.minecraft.block.BlockState;
import net.minecraft.block.NetherPortalBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityPortalEnterEvent;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@ -22,6 +30,11 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(NetherPortalBlock.class)
public class NetherPortalBlockMixin {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityType;spawn(Lnet/minecraft/world/World;Lnet/minecraft/nbt/CompoundNBT;Lnet/minecraft/util/text/ITextComponent;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/SpawnReason;ZZ)Lnet/minecraft/entity/Entity;"))
public Entity arclight$spawn(EntityType<?> entityType, World worldIn, CompoundNBT compound, ITextComponent customName, PlayerEntity playerIn, BlockPos pos, SpawnReason reason, boolean flag, boolean flag1) {
return ((EntityTypeBridge<?>) entityType).bridge$spawnCreature(worldIn, compound, customName, playerIn, pos, reason, flag, flag1, CreatureSpawnEvent.SpawnReason.NETHER_PORTAL);
}
@Inject(method = "trySpawnPortal", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/NetherPortalBlock$Size;placePortalBlocks()V"))
public void arclight$spawnPortal(IWorld worldIn, BlockPos pos, CallbackInfoReturnable<Boolean> cir, NetherPortalBlock.Size size) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.NetherWartBlock;
@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(NetherWartBlock.class)
public class NetherWartBlockMixin_1_15 {
public class NetherWartBlockMixin {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$cropGrow(ServerWorld world, BlockPos pos, BlockState newState, int flags) {

View File

@ -21,6 +21,11 @@ public abstract class NoteBlockMixin implements NoteBlockBridge {
@Shadow protected abstract void triggerNote(World worldIn, BlockPos pos);
// @formatter:on
@Redirect(method = "onBlockActivated", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/NoteBlock;triggerNote(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)V"))
public void arclight$callNote2(NoteBlock noteBlock, World worldIn, BlockPos pos, BlockState blockState) {
this.bridge$play(worldIn, pos, blockState);
}
@Redirect(method = "neighborChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/NoteBlock;triggerNote(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)V"))
public void arclight$callNote1(NoteBlock noteBlock, World worldIn, BlockPos pos, BlockState blockState) {
this.play(worldIn, pos, blockState);

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ObserverBlock;
@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Random;
@Mixin(ObserverBlock.class)
public class ObserverBlockMixin_1_15 {
public class ObserverBlockMixin {
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public void arclight$redstoneChange1(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) {

View File

@ -2,13 +2,17 @@ package io.izzel.arclight.common.mixin.core.block;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.PistonBlock;
import net.minecraft.block.PistonBlockStructureHelper;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.event.block.BlockPistonEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@ -16,8 +20,12 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import java.util.AbstractList;
import java.util.List;
@Mixin(PistonBlock.class)
public class PistonBlockMixin {
@ -36,4 +44,54 @@ public class PistonBlockMixin {
}
}
}
@Inject(method = "doMove", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/block/PistonBlockStructureHelper;getBlocksToDestroy()Ljava/util/List;"))
public void arclight$pistonAction(World worldIn, BlockPos pos, Direction directionIn, boolean extending, CallbackInfoReturnable<Boolean> cir,
BlockPos blockPos, PistonBlockStructureHelper helper) {
final Block craftBlock = CraftBlock.at(worldIn, pos);
final List<BlockPos> moved = helper.getBlocksToMove();
final List<BlockPos> broken = helper.getBlocksToDestroy();
class BlockList extends AbstractList<Block> {
@Override
public int size() {
return moved.size() + broken.size();
}
@Override
public org.bukkit.block.Block get(int index) {
if (index >= size() || index < 0) {
throw new ArrayIndexOutOfBoundsException(index);
}
BlockPos pos = index < moved.size() ? moved.get(index) : broken.get(index - moved.size());
return craftBlock.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
}
}
List<Block> blocks = new BlockList();
Direction direction = extending ? directionIn : directionIn.getOpposite();
BlockPistonEvent event;
if (extending) {
event = new BlockPistonExtendEvent(craftBlock, blocks, CraftBlock.notchToBlockFace(direction));
} else {
event = new BlockPistonRetractEvent(craftBlock, blocks, CraftBlock.notchToBlockFace(direction));
}
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
for (BlockPos b : broken) {
worldIn.notifyBlockUpdate(b, Blocks.AIR.getDefaultState(), worldIn.getBlockState(b), 3);
}
for (BlockPos b : moved) {
worldIn.notifyBlockUpdate(b, Blocks.AIR.getDefaultState(), worldIn.getBlockState(b), 3);
b = b.offset(direction);
worldIn.notifyBlockUpdate(b, Blocks.AIR.getDefaultState(), worldIn.getBlockState(b), 3);
}
cir.setReturnValue(false);
}
}
}

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.RedstoneDiodeBlock;
@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Random;
@Mixin(RedstoneDiodeBlock.class)
public class RedstoneDiodeBlockMixin_1_15 {
public class RedstoneDiodeBlockMixin {
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public void arclight$turnOff(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) {

View File

@ -5,15 +5,25 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.RedstoneLampBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
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.CallbackInfo;
import java.util.Random;
@Mixin(RedstoneLampBlock.class)
public class RedstoneLampBlockMixin {
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private void arclight$redstoneChange(BlockState state, ServerWorld worldIn, BlockPos pos, Random rand, CallbackInfo ci) {
if (CraftEventFactory.callRedstoneChange(worldIn, pos, 15, 0).getNewCurrent() != 0) {
ci.cancel();
}
}
@Inject(method = "neighborChanged", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public void arclight$blockRedstone(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving, CallbackInfo ci) {
if (CraftEventFactory.callRedstoneChange(worldIn, pos, 0, 15).getNewCurrent() != 15) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import net.minecraft.block.BlockState;
@ -26,7 +26,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Random;
@Mixin(RedstoneOreBlock.class)
public abstract class RedstoneOreBlockMixin_1_15 {
public abstract class RedstoneOreBlockMixin {
// @formatter:off
@Shadow private static void activate(BlockState p_196500_0_, World p_196500_1_, BlockPos p_196500_2_) { }

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
import java.util.Random;
@Mixin(ScaffoldingBlock.class)
public class ScaffoldingBlockMixin_1_15 {
public class ScaffoldingBlockMixin {
@Redirect(method = "tick", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/block/BlockState;get(Lnet/minecraft/state/IProperty;)Ljava/lang/Comparable;"))
public Comparable<Integer> arclight$blockFade(BlockState state, IProperty<Integer> property, BlockState blockState, ServerWorld worldIn, BlockPos pos, Random random) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Random;
@Mixin(SnowBlock.class)
public class SnowBlockMixin_1_15 {
public class SnowBlockMixin {
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/block/SnowBlock;spawnDrops(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)V"))
public void arclight$blockFade(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Random;
@Mixin(SpreadableSnowyDirtBlock.class)
public class SpreadableSnowyDirtBlockMixin_1_15 {
public class SpreadableSnowyDirtBlockMixin {
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
public void arclight$blockFade(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.StemBlock;
@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Random;
@Mixin(StemBlock.class)
public class StemBlockMixin_1_15 {
public class StemBlockMixin {
private transient boolean arclight$success = false;

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SugarCaneBlock;
@ -10,9 +10,9 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(SugarCaneBlock.class)
public class SugarCaneBlockMixin_1_15 {
public class SugarCaneBlockMixin {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
public boolean arclight$cropGrow(ServerWorld world, BlockPos pos, BlockState state) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, state);
}

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SweetBerryBushBlock;
@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(SweetBerryBushBlock.class)
public class SweetBerryBushBlockMixin_1_15 {
public class SweetBerryBushBlockMixin {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$cropGrow(ServerWorld world, BlockPos pos, BlockState newState, int flags) {

View File

@ -39,7 +39,7 @@ public abstract class TripWireBlockMixin extends BlockMixin {
BlockState blockstate = worldIn.getBlockState(pos);
boolean flag = blockstate.get(POWERED);
boolean flag1 = false;
List<? extends Entity> list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity) null, blockstate.getShape(worldIn, pos).getBoundingBox().offset(pos));
List<? extends Entity> list = worldIn.getEntitiesWithinAABBExcludingEntity(null, blockstate.getShape(worldIn, pos).getBoundingBox().offset(pos));
if (!list.isEmpty()) {
for (Entity entity : list) {
if (!entity.doesEntityNotTriggerPressurePlate()) {
@ -49,7 +49,7 @@ public abstract class TripWireBlockMixin extends BlockMixin {
}
}
if (flag != flag1 && flag1 && (Boolean) blockstate.get(TripWireBlock.ATTACHED)) {
if (flag != flag1 && flag1 && blockstate.get(TripWireBlock.ATTACHED)) {
org.bukkit.block.Block block = CraftBlock.at(worldIn, pos);
boolean allowed = false;

View File

@ -1,25 +1,61 @@
package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.TurtleEggBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.state.IntegerProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.Cancellable;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityInteractEvent;
import org.spongepowered.asm.mixin.Final;
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;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import java.util.Random;
@Mixin(TurtleEggBlock.class)
public class TurtleEggBlockMixin {
@Shadow @Final public static IntegerProperty HATCH;
@Inject(method = "tick", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/server/ServerWorld;playSound(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/SoundEvent;Lnet/minecraft/util/SoundCategory;FF)V"))
private void arclight$hatch(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci, int i) {
if (!CraftEventFactory.handleBlockGrowEvent(worldIn, pos, state.with(HATCH, i + 1), 2)) {
ci.cancel();
}
}
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private boolean arclight$handledHatch(ServerWorld world, BlockPos pos, BlockState newState, int flags) {
return true;
}
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/server/ServerWorld;playSound(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/SoundEvent;Lnet/minecraft/util/SoundCategory;FF)V"))
private void arclight$born(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, Blocks.AIR.getDefaultState()).isCancelled()) {
ci.cancel();
} else {
((WorldBridge) worldIn).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.EGG);
}
}
@Inject(method = "tryTrample", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/block/TurtleEggBlock;removeOneEgg(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V"))
public void arclight$stepOn(World world, BlockPos pos, Entity entity, int i, CallbackInfo ci) {
Cancellable cancellable;

View File

@ -1,6 +1,5 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.mixin.core.block.BlockMixin;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.VineBlock;
@ -18,7 +17,7 @@ import org.spongepowered.asm.mixin.Shadow;
import java.util.Random;
@Mixin(VineBlock.class)
public abstract class VineBlockMixin_1_15 extends BlockMixin {
public abstract class VineBlockMixin extends BlockMixin {
// @formatter:off
@Shadow protected abstract BlockState func_196545_h(BlockState p_196545_1_, IBlockReader p_196545_2_, BlockPos p_196545_3_);

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.block;
package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.bridge.entity.LivingEntityBridge;
import net.minecraft.block.BlockState;

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.command.impl;
package io.izzel.arclight.common.mixin.core.command.impl;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.network.play.ServerPlayNetHandlerBridge;
@ -26,7 +26,7 @@ import javax.annotation.Nullable;
import java.util.Set;
@Mixin(TeleportCommand.class)
public class TeleportCommandMixin_1_15 {
public class TeleportCommandMixin {
/**
* @author IzzelAliz

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.command.impl;
package io.izzel.arclight.common.mixin.core.command.impl;
import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge;
import net.minecraft.command.impl.TimeCommand;

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.enchantment;
package io.izzel.arclight.common.mixin.core.enchantment;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -18,7 +18,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@Mixin(FrostWalkerEnchantment.class)
public class FrostWalkerEnchantmentMixin_1_15 {
public class FrostWalkerEnchantmentMixin {
/**
* @author IzzelAliz

View File

@ -1,6 +1,7 @@
package io.izzel.arclight.common.mixin.core.entity;
import com.google.common.collect.Lists;
import io.izzel.arclight.common.bridge.entity.AreaEffectCloudEntityBridge;
import io.izzel.arclight.common.bridge.entity.LivingEntityBridge;
import net.minecraft.entity.AreaEffectCloudEntity;
import net.minecraft.entity.Entity;
@ -24,7 +25,6 @@ import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import io.izzel.arclight.common.bridge.entity.AreaEffectCloudEntityBridge;
import javax.annotation.Nullable;
import java.util.Iterator;
@ -80,7 +80,7 @@ public abstract class AreaEffectCloudEntityMixin extends EntityMixin implements
int k = j >> 16 & 255;
int l = j >> 8 & 255;
int i1 = j & 255;
this.world.addOptionalParticle(iparticledata, this.posX + (double) f3, this.posY, this.posZ + (double) f4, (double) ((float) k / 255.0F), (double) ((float) l / 255.0F), (double) ((float) i1 / 255.0F));
this.world.addOptionalParticle(iparticledata, this.posX + (double) f3, this.posY, this.posZ + (double) f4, (float) k / 255.0F, (float) l / 255.0F, (float) i1 / 255.0F);
} else {
this.world.addOptionalParticle(iparticledata, this.posX + (double) f3, this.posY, this.posZ + (double) f4, 0.0D, 0.0D, 0.0D);
}
@ -99,9 +99,9 @@ public abstract class AreaEffectCloudEntityMixin extends EntityMixin implements
int i2 = l1 >> 16 & 255;
int j2 = l1 >> 8 & 255;
int j1 = l1 & 255;
this.world.addOptionalParticle(iparticledata, this.posX + (double) f8, this.posY, this.posZ + (double) f9, (double) ((float) i2 / 255.0F), (double) ((float) j2 / 255.0F), (double) ((float) j1 / 255.0F));
this.world.addOptionalParticle(iparticledata, this.posX + (double) f8, this.posY, this.posZ + (double) f9, (float) i2 / 255.0F, (float) j2 / 255.0F, (float) j1 / 255.0F);
} else {
this.world.addOptionalParticle(iparticledata, this.posX + (double) f8, this.posY, this.posZ + (double) f9, (0.5D - this.rand.nextDouble()) * 0.15D, (double) 0.01F, (0.5D - this.rand.nextDouble()) * 0.15D);
this.world.addOptionalParticle(iparticledata, this.posX + (double) f8, this.posY, this.posZ + (double) f9, (0.5D - this.rand.nextDouble()) * 0.15D, 0.01F, (0.5D - this.rand.nextDouble()) * 0.15D);
}
}
}

View File

@ -9,6 +9,7 @@ import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.common.bridge.world.storage.SaveHandlerBridge;
import io.izzel.arclight.common.mod.util.ArclightCaptures;
import net.minecraft.block.pattern.BlockPattern;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
@ -27,16 +28,22 @@ import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.scoreboard.Team;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Direction;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.Heightmap;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.util.ITeleporter;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.block.BlockFace;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v.CraftServer;
import org.bukkit.craftbukkit.v.CraftWorld;
@ -50,15 +57,18 @@ import org.bukkit.event.entity.EntityCombustByBlockEvent;
import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDropItemEvent;
import org.bukkit.event.entity.EntityPortalEvent;
import org.bukkit.event.entity.EntityPoseChangeEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.plugin.PluginManager;
import org.bukkit.projectiles.ProjectileSource;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@ -166,6 +176,14 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
@Shadow @Nullable public abstract Entity changeDimension(DimensionType destination);
@Shadow public abstract boolean isRidingSameEntity(Entity entityIn);
@Shadow public abstract boolean isInvulnerable();
@Shadow public abstract double getPosX();
@Shadow public abstract double getPosZ();
@Shadow public abstract Vec3d getLastPortalVec();
@Shadow public abstract double getPosY();
@Shadow public abstract Direction getTeleportDirection();
@Shadow public abstract double getPosYEye();
@Shadow public abstract Vec3d getPositionVec();
@Shadow(remap = false) public abstract void revive();
// @formatter:on
private static final int CURRENT_LEVEL = 2;
@ -729,4 +747,136 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
return teleportTo(type, blockPos);
}
@Inject(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;canTriggerWalking()Z"))
private void arclight$move$blockCollide(MoverType typeIn, Vec3d pos, CallbackInfo ci) {
if (collidedHorizontally && this.bridge$getBukkitEntity() instanceof Vehicle) {
Vehicle vehicle = (Vehicle) this.bridge$getBukkitEntity();
org.bukkit.block.Block block = ((WorldBridge) this.world).bridge$getWorld().getBlockAt(MathHelper.floor(this.getPosX()), MathHelper.floor(this.getPosY()), MathHelper.floor(this.getPosZ()));
Vec3d vec3d = this.getAllowedMovement(pos);
if (pos.x > vec3d.x) {
block = block.getRelative(BlockFace.EAST);
} else if (vec3d.x < vec3d.x) {
block = block.getRelative(BlockFace.WEST);
} else if (pos.z > vec3d.z) {
block = block.getRelative(BlockFace.SOUTH);
} else if (pos.z < vec3d.z) {
block = block.getRelative(BlockFace.NORTH);
}
if (block.getType() != org.bukkit.Material.AIR) {
VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, block);
Bukkit.getPluginManager().callEvent(event);
}
}
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite(remap = false)
@Nullable
public Entity changeDimension(DimensionType destination, ITeleporter teleporter) {
BlockPos location = ((InternalEntityBridge) this).internal$capturedPos();
if (!ForgeHooks.onTravelToDimension((Entity) (Object) this, destination)) return null;
if (!this.world.isRemote && !this.removed) {
this.world.getProfiler().startSection("changeDimension");
MinecraftServer minecraftserver = this.getServer();
DimensionType dimensiontype = this.dimension;
ServerWorld serverworld = minecraftserver.getWorld(dimensiontype);
ServerWorld[] serverworld1 = new ServerWorld[]{minecraftserver.getWorld(destination)};
if (serverworld1 == null) {
return null;
}
//this.dimension = destination;
//this.detach();
this.world.getProfiler().startSection("reposition");
Entity transportedEntity = teleporter.placeEntity((Entity) (Object) this, serverworld, serverworld1[0], this.rotationYaw, spawnPortal -> { //Forge: Start vanilla logic
Vec3d vec3d = this.getMotion();
float f = 0.0F;
BlockPos blockpos = location;
if (blockpos == null) {
if (dimensiontype == DimensionType.THE_END && destination == DimensionType.OVERWORLD) {
EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent((Entity) (Object) this, serverworld1[0], serverworld1[0].getHeight(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, serverworld1[0].getSpawnPoint()), 0);
if (event == null) {
return null;
}
serverworld1[0] = ((CraftWorld) event.getTo().getWorld()).getHandle();
blockpos = new BlockPos(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
//blockpos = serverworld1[0].getHeight(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, serverworld1[0].getSpawnPoint());
} else if (destination == DimensionType.THE_END) {
EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent((Entity) (Object) this, serverworld1[0], (serverworld1[0].getSpawnCoordinate() != null) ? serverworld1[0].getSpawnCoordinate() : serverworld1[0].getSpawnPoint(), 0);
if (event == null) {
return null;
}
serverworld1[0] = ((CraftWorld) event.getTo().getWorld()).getHandle();
blockpos = new BlockPos(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
//blockpos = serverworld1[0].getSpawnCoordinate();
} else {
double movementFactor = serverworld.getDimension().getMovementFactor() / serverworld1[0].getDimension().getMovementFactor();
double d0 = this.getPosX() * movementFactor;
double d1 = this.getPosZ() * movementFactor;
double d3 = Math.min(-2.9999872E7D, serverworld1[0].getWorldBorder().minX() + 16.0D);
double d4 = Math.min(-2.9999872E7D, serverworld1[0].getWorldBorder().minZ() + 16.0D);
double d5 = Math.min(2.9999872E7D, serverworld1[0].getWorldBorder().maxX() - 16.0D);
double d6 = Math.min(2.9999872E7D, serverworld1[0].getWorldBorder().maxZ() - 16.0D);
d0 = MathHelper.clamp(d0, d3, d5);
d1 = MathHelper.clamp(d1, d4, d6);
Vec3d vec3d1 = this.getLastPortalVec();
blockpos = new BlockPos(d0, this.getPosY(), d1);
EntityPortalEvent event2 = CraftEventFactory.callEntityPortalEvent((Entity) (Object) this, serverworld1[0], blockpos, 128);
if (event2 == null) {
return null;
}
serverworld1[0] = ((CraftWorld) event2.getTo().getWorld()).getHandle();
blockpos = new BlockPos(event2.getTo().getX(), event2.getTo().getY(), event2.getTo().getZ());
int searchRadius = event2.getSearchRadius();
// todo 实现 radius
if (spawnPortal) {
BlockPattern.PortalInfo blockpattern$portalinfo = serverworld1[0].getDefaultTeleporter().placeInExistingPortal(blockpos, vec3d, this.getTeleportDirection(), vec3d1.x, vec3d1.y, (Object) this instanceof PlayerEntity);
if (blockpattern$portalinfo == null) {
return null;
}
blockpos = new BlockPos(blockpattern$portalinfo.pos);
vec3d = blockpattern$portalinfo.motion;
f = (float) blockpattern$portalinfo.rotation;
}
}
}
this.dimension = destination;
this.detach();
this.world.getProfiler().endStartSection("reloading");
Entity entity = this.getType().create(serverworld1[0]);
if (entity != null) {
entity.copyDataFromOld((Entity) (Object) this);
entity.moveToBlockPosAndAngles(blockpos, entity.rotationYaw + f, entity.rotationPitch);
entity.setMotion(vec3d);
serverworld1[0].addFromAnotherDimension(entity);
((InternalEntityBridge) this).internal$getBukkitEntity().setHandle(entity);
((EntityBridge) entity).bridge$setBukkitEntity(((InternalEntityBridge) this).internal$getBukkitEntity());
if ((Object) this instanceof MobEntity) {
((MobEntity) (Object) this).clearLeashed(true, false);
}
}
return entity;
});//Forge: End vanilla logic
this.remove(false);
this.world.getProfiler().endSection();
serverworld.resetUpdateEntityTick();
serverworld1[0].resetUpdateEntityTick();
this.world.getProfiler().endSection();
return transportedEntity;
} else {
return null;
}
}
}

View File

@ -1,6 +1,9 @@
package io.izzel.arclight.common.mixin.core.entity;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.mojang.datafixers.util.Either;
import io.izzel.arclight.common.bridge.entity.LivingEntityBridge;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
@ -12,6 +15,7 @@ import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AbstractAttributeMap;
import net.minecraft.entity.ai.attributes.IAttribute;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import net.minecraft.entity.item.ExperienceOrbEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.passive.TameableEntity;
@ -25,6 +29,7 @@ import net.minecraft.nbt.FloatNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.IntNBT;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
@ -39,7 +44,9 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.world.GameRules;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.entity.living.PotionEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v.attribute.CraftAttributeMap;
@ -67,6 +74,10 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
@ -143,7 +154,16 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt
@Shadow public abstract ItemStack getHeldItemOffhand();
@Shadow public abstract Random getRNG();
@Shadow public abstract Optional<BlockPos> getBedPosition();
@Shadow public abstract boolean addPotionEffect(EffectInstance effectInstanceIn);
@Shadow @Final private static DataParameter<Integer> POTION_EFFECTS;
@Shadow @Final private static DataParameter<Boolean> HIDE_PARTICLES;
@Shadow @Final public Map<Effect, EffectInstance> activePotionsMap;
@Shadow protected abstract void onFinishedPotionEffect(EffectInstance effect);
@Shadow protected abstract void onChangedPotionEffect(EffectInstance id, boolean reapply);
@Shadow protected abstract void updatePotionMetadata();
@Shadow public abstract boolean isPotionApplicable(EffectInstance potioneffectIn);
@Shadow protected abstract void onNewPotionEffect(EffectInstance id);
@Shadow @Nullable public abstract EffectInstance removeActivePotionEffect(@Nullable Effect potioneffectin);
@Shadow protected abstract void createWitherRose(@Nullable LivingEntity p_226298_1_);
// @formatter:on
public int expToDrop;
@ -159,6 +179,217 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt
this.collides = true;
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
protected void onDeathUpdate() {
++this.deathTime;
if (this.deathTime >= 20 && !this.removed) {
this.remove((Object) this instanceof ServerPlayerEntity); //Forge keep data until we revive player
for (int k = 0; k < 20; ++k) {
double d2 = this.rand.nextGaussian() * 0.02D;
double d0 = this.rand.nextGaussian() * 0.02D;
double d1 = this.rand.nextGaussian() * 0.02D;
this.world.addParticle(ParticleTypes.POOF, this.getPosX() + (double) (this.rand.nextFloat() * this.getWidth() * 2.0F) - (double) this.getWidth(), this.getPosY() + (double) (this.rand.nextFloat() * this.getHeight()), this.getPosZ() + (double) (this.rand.nextFloat() * this.getWidth() * 2.0F) - (double) this.getWidth(), d2, d0, d1);
}
}
}
@Redirect(method = "spawnDrops", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;dropExperience()V"))
private void arclight$dropLater(LivingEntity livingEntity) {
}
@Inject(method = "spawnDrops", at = @At("RETURN"))
private void arclight$dropLast(DamageSource damageSourceIn, CallbackInfo ci) {
this.dropExperience();
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
protected void dropExperience() {
// if (!this.world.isRemote && (this.isPlayer() || this.recentlyHit > 0 && this.canDropLoot() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT))) {
if (true) {
int i = bridge$getExpToDrop();
while (i > 0) {
int j = ExperienceOrbEntity.getXPSplit(i);
i -= j;
this.world.addEntity(new ExperienceOrbEntity(this.world, this.getPosX(), this.getPosY(), this.getPosZ(), j));
}
bridge$setExpToDrop(0);
}
}
private boolean isTickingEffects = false;
private List<Map.Entry<Either<EffectInstance, Effect>, EntityPotionEffectEvent.Cause>> effectsToProcess = Lists.newArrayList();
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
protected void updatePotionEffects() {
this.isTickingEffects = true;
Iterator<Effect> iterator = this.activePotionsMap.keySet().iterator();
try {
while (iterator.hasNext()) {
Effect effect = iterator.next();
EffectInstance effectinstance = this.activePotionsMap.get(effect);
if (!effectinstance.tick((LivingEntity) (Object) this, () -> {
onChangedPotionEffect(effectinstance, true);
})) {
if (!this.world.isRemote && !MinecraftForge.EVENT_BUS.post(new PotionEvent.PotionExpiryEvent((LivingEntity) (Object) this, effectinstance))) {
EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent((LivingEntity) (Object) this, effectinstance, null, EntityPotionEffectEvent.Cause.EXPIRATION);
if (event.isCancelled()) {
continue;
}
iterator.remove();
this.onFinishedPotionEffect(effectinstance);
}
} else if (effectinstance.getDuration() % 600 == 0) {
this.onChangedPotionEffect(effectinstance, false);
}
}
} catch (ConcurrentModificationException ignored) {
}
isTickingEffects = false;
for (Map.Entry<Either<EffectInstance, Effect>, EntityPotionEffectEvent.Cause> e : effectsToProcess) {
Either<EffectInstance, Effect> either = e.getKey();
EntityPotionEffectEvent.Cause cause = e.getValue();
bridge$pushEffectCause(cause);
if (either.left().isPresent()) {
addPotionEffect(either.left().get());
} else {
removePotionEffect(either.right().get());
}
}
effectsToProcess.clear();
if (this.potionsNeedUpdate) {
if (!this.world.isRemote) {
this.updatePotionMetadata();
}
this.potionsNeedUpdate = false;
}
int i = this.dataManager.get(POTION_EFFECTS);
boolean flag1 = this.dataManager.get(HIDE_PARTICLES);
if (i > 0) {
boolean flag;
if (this.isInvisible()) {
flag = this.rand.nextInt(15) == 0;
} else {
flag = this.rand.nextBoolean();
}
if (flag1) {
flag &= this.rand.nextInt(5) == 0;
}
if (flag && i > 0) {
double d0 = (double) (i >> 16 & 255) / 255.0D;
double d1 = (double) (i >> 8 & 255) / 255.0D;
double d2 = (double) (i >> 0 & 255) / 255.0D;
this.world.addParticle(flag1 ? ParticleTypes.AMBIENT_ENTITY_EFFECT : ParticleTypes.ENTITY_EFFECT, this.getPosX() + (this.rand.nextDouble() - 0.5D) * (double) this.getWidth(), this.getPosY() + this.rand.nextDouble() * (double) this.getHeight(), this.getPosZ() + (this.rand.nextDouble() - 0.5D) * (double) this.getWidth(), d0, d1, d2);
}
}
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public boolean addPotionEffect(EffectInstance effectInstanceIn) {
EntityPotionEffectEvent.Cause cause = bridge$getEffectCause().orElse(EntityPotionEffectEvent.Cause.UNKNOWN);
if (isTickingEffects) {
effectsToProcess.add(Maps.immutableEntry(Either.left(effectInstanceIn), cause));
return true;
}
if (!this.isPotionApplicable(effectInstanceIn)) {
return false;
} else {
EffectInstance effectinstance = this.activePotionsMap.get(effectInstanceIn.getPotion());
boolean override = false;
if (effectinstance != null) {
override = new EffectInstance(effectinstance).combine(effectInstanceIn);
}
EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent((LivingEntity) (Object) this, effectinstance, effectInstanceIn, cause, override);
if (event.isCancelled()) {
return false;
}
MinecraftForge.EVENT_BUS.post(new PotionEvent.PotionAddedEvent((LivingEntity) (Object) this, effectinstance, effectInstanceIn));
if (effectinstance == null) {
this.activePotionsMap.put(effectInstanceIn.getPotion(), effectInstanceIn);
this.onNewPotionEffect(effectInstanceIn);
return true;
} else if (event.isOverride()) {
effectinstance.combine(effectInstanceIn);
this.onChangedPotionEffect(effectinstance, true);
return true;
} else {
return false;
}
}
}
@SuppressWarnings("unused") // mock
public EffectInstance c(@Nullable Effect potioneffectin, EntityPotionEffectEvent.Cause cause) {
bridge$pushEffectCause(cause);
return removeActivePotionEffect(potioneffectin);
}
@Inject(method = "removeActivePotionEffect", cancellable = true, at = @At("HEAD"))
public void arclight$clearActive(Effect effect, CallbackInfoReturnable<EffectInstance> cir) {
EntityPotionEffectEvent.Cause cause = bridge$getEffectCause().orElse(EntityPotionEffectEvent.Cause.UNKNOWN);
if (isTickingEffects) {
effectsToProcess.add(Maps.immutableEntry(Either.right(effect), cause));
cir.setReturnValue(null);
return;
}
EffectInstance effectInstance = this.activePotionsMap.get(effect);
if (effectInstance == null) {
cir.setReturnValue(null);
return;
}
EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent((LivingEntity) (Object) this, effectInstance, null, cause);
if (event.isCancelled()) {
cir.setReturnValue(null);
}
}
private transient boolean arclight$fallSuccess;
@Inject(method = "onLivingFall", cancellable = true, at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/entity/LivingEntity;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z"))
public void arclight$fall(float distance, float damageMultiplier, CallbackInfoReturnable<Boolean> cir) {
if (!arclight$fallSuccess) {
cir.setReturnValue(true);
}
}
@Redirect(method = "onLivingFall", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z"))
public boolean arclight$fall(LivingEntity livingEntity, DamageSource source, float amount) {
return arclight$fallSuccess = livingEntity.attackEntityFrom(source, amount);
}
@Override
public boolean bridge$canPickUpLoot() {
return canPickUpLoot;

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.entity.ai.goal;
package io.izzel.arclight.common.mixin.core.entity.ai.goal;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import net.minecraft.entity.ai.goal.FollowOwnerGoal;
@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(FollowOwnerGoal.class)
public class FollowOwnerGoalMixin_1_15 {
public class FollowOwnerGoalMixin {
// @formatter:off
@Shadow @Final private TameableEntity tameable;

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.entity.boss;
package io.izzel.arclight.common.mixin.core.entity.boss;
import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin;
import net.minecraft.block.BlockState;
@ -27,7 +27,7 @@ import org.spongepowered.asm.mixin.Shadow;
import java.util.List;
@Mixin(WitherEntity.class)
public abstract class WitherEntityMixin_1_15 extends CreatureEntityMixin {
public abstract class WitherEntityMixin extends CreatureEntityMixin {
// @formatter:off
@Shadow public abstract int getInvulTime();
@ -56,7 +56,7 @@ public abstract class WitherEntityMixin_1_15 extends CreatureEntityMixin {
ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.world.createExplosion((WitherEntity) (Object) this, this.posX, this.bridge$getEyeHeight(), this.posZ, event.getRadius(), event.getFire(), explosion$mode);
this.world.createExplosion((WitherEntity) (Object) this, this.posX, this.getPosYEye(), this.posZ, event.getRadius(), event.getFire(), explosion$mode);
}
this.world.playBroadcastSound(1023, new BlockPos((WitherEntity) (Object) this), 0);
}

View File

@ -1,16 +1,27 @@
package io.izzel.arclight.common.mixin.core.entity.item;
import com.google.common.collect.Lists;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import io.izzel.arclight.common.mixin.core.entity.LivingEntityMixin;
import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.GameRules;
import net.minecraft.world.World;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.CraftEquipmentSlot;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.craftbukkit.v.inventory.CraftItemStack;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@ -27,7 +38,10 @@ import java.util.stream.Collectors;
@Mixin(ArmorStandEntity.class)
public abstract class ArmorStandEntityMixin extends LivingEntityMixin {
// @formatter:off
@Shadow private boolean canInteract;
@Shadow public abstract ItemStack getItemStackFromSlot(EquipmentSlotType slotIn);
// @formatter:on
@Override
public float getBukkitYaw() {
@ -123,4 +137,23 @@ public abstract class ArmorStandEntityMixin extends LivingEntityMixin {
}
CraftEventFactory.callEntityDeathEvent((ArmorStandEntity) (Object) this, drops);
}
@Inject(method = "func_226529_a_", cancellable = true, at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;abilities:Lnet/minecraft/entity/player/PlayerAbilities;"))
public void arclight$manipulateEvent(PlayerEntity playerEntity, EquipmentSlotType slotType, ItemStack itemStack, Hand hand, CallbackInfoReturnable<Boolean> cir) {
ItemStack itemStack1 = this.getItemStackFromSlot(slotType);
org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemStack1);
org.bukkit.inventory.ItemStack playerHeldItem = CraftItemStack.asCraftMirror(itemStack);
Player player = ((ServerPlayerEntityBridge) playerEntity).bridge$getBukkitEntity();
ArmorStand self = (ArmorStand) ((EntityBridge) this).bridge$getBukkitEntity();
EquipmentSlot slot = CraftEquipmentSlot.getSlot(slotType);
PlayerArmorStandManipulateEvent event = new PlayerArmorStandManipulateEvent(player, self, playerHeldItem, armorStandItem, slot);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
cir.setReturnValue(true);
}
}
}

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.entity.item;
package io.izzel.arclight.common.mixin.core.entity.item;
import io.izzel.arclight.common.mixin.core.entity.EntityMixin;
import net.minecraft.block.Block;
@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(FallingBlockEntity.class)
public abstract class FallingBlockEntityMixin_1_15 extends EntityMixin {
public abstract class FallingBlockEntityMixin extends EntityMixin {
@Shadow private BlockState fallTile;

View File

@ -23,6 +23,7 @@ import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@ -121,4 +122,11 @@ public abstract class ItemEntityMixin extends EntityMixin {
private void arclight$markDirty(ItemStack stack, CallbackInfo ci) {
((EntityDataManagerBridge) this.getDataManager()).bridge$markDirty(ITEM);
}
@Redirect(method = "func_226531_a_", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/ItemEntity;setItem(Lnet/minecraft/item/ItemStack;)V"))
private static void arclight$setNonEmpty(ItemEntity itemEntity, ItemStack stack) {
if (!stack.isEmpty()) {
itemEntity.setItem(stack);
}
}
}

View File

@ -36,7 +36,7 @@ public abstract class LeashKnotEntityMixin extends HangingEntityMixin {
}
boolean flag = false;
final double d0 = 7.0;
final List<MobEntity> list = this.world.getEntitiesWithinAABB((Class<? extends MobEntity>) MobEntity.class, new AxisAlignedBB(this.posX - 7.0, this.posY - 7.0, this.posZ - 7.0, this.posX + 7.0, this.posY + 7.0, this.posZ + 7.0));
final List<MobEntity> list = this.world.getEntitiesWithinAABB(MobEntity.class, new AxisAlignedBB(this.posX - 7.0, this.posY - 7.0, this.posZ - 7.0, this.posX + 7.0, this.posY + 7.0, this.posZ + 7.0));
for (final MobEntity entityinsentient : list) {
if (entityinsentient.getLeashHolder() == entityhuman) {
if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, (LeashKnotEntity) (Object) this, entityhuman).isCancelled()) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.entity.monster;
package io.izzel.arclight.common.mixin.core.entity.monster;
import io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge;
import net.minecraft.entity.Entity;

View File

@ -3,10 +3,16 @@ package io.izzel.arclight.common.mixin.core.entity.monster;
import io.izzel.arclight.common.bridge.entity.monster.EndermanEntityBridge;
import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import net.minecraft.entity.monster.EndermanEntity;
import net.minecraft.network.datasync.DataParameter;
import org.bukkit.event.entity.EntityTargetEvent;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import javax.annotation.Nullable;
import java.util.concurrent.atomic.AtomicBoolean;
@ -14,6 +20,30 @@ import java.util.concurrent.atomic.AtomicBoolean;
@Mixin(EndermanEntity.class)
public abstract class EndermanEntityMixin extends CreatureEntityMixin implements EndermanEntityBridge {
// @formatter:off
@Shadow private int targetChangeTime;
@Shadow @Final private static DataParameter<Boolean> SCREAMING;
@Shadow @Final private static DataParameter<Boolean> field_226535_bx_;
@Shadow @Final private static AttributeModifier ATTACKING_SPEED_BOOST;
// @formatter:on
@Override
public void bridge$updateTarget(LivingEntity livingEntity) {
IAttributeInstance iattributeinstance = this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
if (livingEntity == null) {
this.targetChangeTime = 0;
this.dataManager.set(SCREAMING, false);
this.dataManager.set(field_226535_bx_, false);
iattributeinstance.removeModifier(ATTACKING_SPEED_BOOST);
} else {
this.targetChangeTime = this.ticksExisted;
this.dataManager.set(SCREAMING, true);
if (!iattributeinstance.hasModifier(ATTACKING_SPEED_BOOST)) {
iattributeinstance.applyModifier(ATTACKING_SPEED_BOOST);
}
}
}
@Override
public boolean setGoalTarget(LivingEntity livingEntity, EntityTargetEvent.TargetReason reason, boolean fireEvent) {
if (!super.setGoalTarget(livingEntity, reason, fireEvent)) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.entity.monster;
package io.izzel.arclight.common.mixin.core.entity.monster;
import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin;
import net.minecraft.block.Blocks;
@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(RavagerEntity.class)
public abstract class RavagerEntityMixin_1_15 extends CreatureEntityMixin {
public abstract class RavagerEntityMixin extends CreatureEntityMixin {
@Redirect(method = "livingTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;destroyBlock(Lnet/minecraft/util/math/BlockPos;ZLnet/minecraft/entity/Entity;)Z"))
private boolean arclight$entityChangeBlock(World world, BlockPos pos, boolean p_225521_2_, Entity entityIn) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.entity.monster;
package io.izzel.arclight.common.mixin.core.entity.monster;
import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin;
import net.minecraft.entity.monster.ShulkerEntity;
@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ShulkerEntity.class)
public abstract class ShulkerEntityMixin_1_15 extends CreatureEntityMixin {
public abstract class ShulkerEntityMixin extends CreatureEntityMixin {
@Inject(method = "notifyDataManagerChange", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/entity/monster/ShulkerEntity;forceSetPosition(DDD)V"))
private void arclight$chunkCheck(DataParameter<?> key, CallbackInfo ci) {

View File

@ -1,7 +1,6 @@
package io.izzel.arclight.common.mixin.v1_15.entity.monster;
package io.izzel.arclight.common.mixin.core.entity.monster;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.mixin.core.entity.monster.ZombieEntityMixin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.monster.ZombiePigmanEntity;
@ -18,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ZombiePigmanEntity.class)
public abstract class ZombiePigmanEntityMixin_1_15 extends ZombieEntityMixin {
public abstract class ZombiePigmanEntityMixin extends ZombieEntityMixin {
// @formatter:off
@Shadow protected abstract boolean func_226547_i_(LivingEntity p_70835_1_);

View File

@ -1,7 +1,6 @@
package io.izzel.arclight.common.mixin.v1_15.entity.passive;
package io.izzel.arclight.common.mixin.core.entity.passive;
import io.izzel.arclight.common.bridge.entity.LivingEntityBridge;
import io.izzel.arclight.common.mixin.core.entity.passive.AnimalEntityMixin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.passive.BeeEntity;

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.entity.passive;
package io.izzel.arclight.common.mixin.core.entity.passive;
import io.izzel.arclight.common.bridge.entity.MobEntityBridge;
import net.minecraft.entity.LivingEntity;

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.entity.passive;
package io.izzel.arclight.common.mixin.core.entity.passive;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;

View File

@ -1,6 +1,7 @@
package io.izzel.arclight.common.mixin.core.entity.player;
import com.mojang.authlib.GameProfile;
import com.mojang.datafixers.util.Either;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.entity.InternalEntityBridge;
import io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge;
@ -8,6 +9,7 @@ import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import io.izzel.arclight.common.bridge.inventory.IInventoryBridge;
import io.izzel.arclight.common.bridge.util.DamageSourceBridge;
import io.izzel.arclight.common.bridge.util.FoodStatsBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge;
import io.izzel.arclight.common.mixin.core.entity.LivingEntityMixin;
import net.minecraft.enchantment.EnchantmentHelper;
@ -37,32 +39,37 @@ import net.minecraft.scoreboard.Scoreboard;
import net.minecraft.stats.Stat;
import net.minecraft.stats.Stats;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Direction;
import net.minecraft.util.FoodStats;
import net.minecraft.util.Hand;
import net.minecraft.util.HandSide;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.Unit;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.Difficulty;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.ForgeHooks;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.craftbukkit.v.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.craftbukkit.v.util.CraftVector;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.entity.EntityPotionEffectEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.player.PlayerBedLeaveEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.scoreboard.Team;
@ -115,6 +122,9 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
@Shadow protected boolean isMovementBlocked() { return false; }
@Shadow public abstract Scoreboard getWorldScoreboard();
@Shadow protected EnderChestInventory enterChestInventory;
@Shadow public abstract Either<PlayerEntity.SleepResult, Unit> trySleep(BlockPos at);
@Shadow public abstract void startSleeping(BlockPos p_213342_1_);
@Shadow public int sleepTimer;
// @formatter:on
public boolean fauxSleeping;
@ -125,7 +135,104 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
private void arclight$init(World worldIn, GameProfile gameProfileIn, CallbackInfo ci) {
oldLevel = -1;
((FoodStatsBridge) this.foodStats).bridge$setEntityHuman((PlayerEntity) (Object) this);
((IInventoryBridge) this.enterChestInventory).setOwner(((HumanEntity) this.getBukkitEntity()));
((IInventoryBridge) this.enterChestInventory).setOwner(this.getBukkitEntity());
}
private boolean arclight$forceSleep = false;
private Object arclight$processSleep = null;
private Either<PlayerEntity.SleepResult, Unit> getBedResult(BlockPos at, Direction direction) {
arclight$processSleep = true;
Either<PlayerEntity.SleepResult, Unit> either = this.trySleep(at);
arclight$processSleep = null;
return either;
}
public Either<PlayerEntity.SleepResult, Unit> sleep(BlockPos at, boolean force) {
arclight$forceSleep = force;
try {
return this.trySleep(at);
} finally {
arclight$forceSleep = false;
}
}
@Inject(method = "trySleep", cancellable = true, at = @At(value = "HEAD"))
public void arclight$onSleep(BlockPos at, CallbackInfoReturnable<Either<PlayerEntity.SleepResult, Unit>> cir) {
if (arclight$processSleep == null) {
Either<PlayerEntity.SleepResult, Unit> result = getBedResult(at, null);
if (result.left().orElse(null) == PlayerEntity.SleepResult.OTHER_PROBLEM) {
cir.setReturnValue(result);
return;
}
if (arclight$forceSleep) {
result = Either.right(Unit.INSTANCE);
}
if (this.bridge$getBukkitEntity() instanceof Player) {
result = CraftEventFactory.callPlayerBedEnterEvent((PlayerEntity) (Object) this, at, result);
if (result.left().isPresent()) {
cir.setReturnValue(result);
return;
}
}
this.startSleeping(at);
this.sleepTimer = 0;
if (this.world instanceof ServerWorld) {
((ServerWorld) this.world).updateAllPlayersSleepingFlag();
}
cir.setReturnValue(Either.right(Unit.INSTANCE));
}
}
@Inject(method = "trySleep", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;startSleeping(Lnet/minecraft/util/math/BlockPos;)V"))
public void arclight$preSleep(BlockPos at, CallbackInfoReturnable<Either<PlayerEntity.SleepResult, Unit>> cir) {
if (arclight$processSleep != null) {
cir.setReturnValue(Either.right(Unit.INSTANCE));
}
}
@Inject(method = "stopSleepInBed", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;sleepTimer:I"))
private void arclight$wakeup(boolean flag, boolean flag1, CallbackInfo ci) {
BlockPos blockPos = this.getBedPosition().orElse(null);
if (this.bridge$getBukkitEntity() instanceof Player) {
Player player = (Player) this.bridge$getBukkitEntity();
Block bed;
if (blockPos != null) {
bed = CraftBlock.at(this.world, blockPos);
} else {
bed = ((WorldBridge) this.world).bridge$getWorld().getBlockAt(player.getLocation());
}
PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed, true);
Bukkit.getPluginManager().callEvent(event);
}
}
@Inject(method = "setSpawnPoint", remap = false, at = @At("RETURN"))
private void arclight$updateSpawnpoint(BlockPos pos, boolean p_226560_2_, boolean p_226560_3_, DimensionType dim, CallbackInfo ci) {
bridge$setSpawnWorld(pos == null ? "" : this.world.worldInfo.getWorldName());
}
@Inject(method = "startFallFlying", cancellable = true, at = @At("HEAD"))
private void arclight$startGlidingEvent(CallbackInfo ci) {
if (CraftEventFactory.callToggleGlideEvent((PlayerEntity) (Object) this, true).isCancelled()) {
this.setFlag(7, true);
this.setFlag(7, false);
ci.cancel();
}
}
@Inject(method = "stopFallFlying", cancellable = true, at = @At("HEAD"))
private void arclight$stopGlidingEvent(CallbackInfo ci) {
if (CraftEventFactory.callToggleGlideEvent((PlayerEntity) (Object) this, false).isCancelled()) {
ci.cancel();
}
}
@Override
public Either<PlayerEntity.SleepResult, Unit> bridge$trySleep(BlockPos at, boolean force) {
return sleep(at, force);
}
@Override
@ -328,7 +435,7 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla
}
if (flag4) {
final float f5 = 1.0f + EnchantmentHelper.getSweepingDamageRatio((PlayerEntity) (Object) this) * f;
final List<LivingEntity> list = this.world.getEntitiesWithinAABB((Class<? extends LivingEntity>) LivingEntity.class, entity.getBoundingBox().grow(1.0, 0.25, 1.0));
final List<LivingEntity> list = this.world.getEntitiesWithinAABB(LivingEntity.class, entity.getBoundingBox().grow(1.0, 0.25, 1.0));
for (final LivingEntity entityliving : list) {
if (entityliving != (Object) this && entityliving != entity && !this.isOnSameTeam(entityliving) && (!(entityliving instanceof ArmorStandEntity) || !((ArmorStandEntity) entityliving).hasMarker()) && this.getDistanceSq(entityliving) < 9.0 && entityliving.attackEntityFrom(((DamageSourceBridge) DamageSource.causePlayerDamage((PlayerEntity) (Object) this)).bridge$sweep(), f5)) {
entityliving.knockBack((PlayerEntity) (Object) this, 0.4f, MathHelper.sin(this.rotationYaw * 0.017453292f), -MathHelper.cos(this.rotationYaw * 0.017453292f));

View File

@ -1,14 +1,22 @@
package io.izzel.arclight.common.mixin.core.entity.player;
import com.google.common.collect.Lists;
import com.mojang.datafixers.util.Either;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.entity.InternalEntityBridge;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import io.izzel.arclight.common.bridge.inventory.container.ContainerBridge;
import io.izzel.arclight.common.bridge.network.play.ServerPlayNetHandlerBridge;
import io.izzel.arclight.common.bridge.util.FoodStatsBridge;
import io.izzel.arclight.common.bridge.world.TeleporterBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge;
import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge;
import io.izzel.arclight.common.mod.util.ArclightCaptures;
import io.izzel.arclight.common.mod.util.ChestBlockDoubleInventoryHacks;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.block.Blocks;
import net.minecraft.block.pattern.BlockPattern;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ItemEntity;
@ -28,14 +36,21 @@ import net.minecraft.network.play.client.CClientSettingsPacket;
import net.minecraft.network.play.server.SChangeGameStatePacket;
import net.minecraft.network.play.server.SCombatPacket;
import net.minecraft.network.play.server.SOpenHorseWindowPacket;
import net.minecraft.network.play.server.SPlayEntityEffectPacket;
import net.minecraft.network.play.server.SPlaySoundEventPacket;
import net.minecraft.network.play.server.SPlayerAbilitiesPacket;
import net.minecraft.network.play.server.SRespawnPacket;
import net.minecraft.network.play.server.SServerDifficultyPacket;
import net.minecraft.network.play.server.SSetSlotPacket;
import net.minecraft.network.play.server.SUpdateHealthPacket;
import net.minecraft.potion.EffectInstance;
import net.minecraft.scoreboard.Score;
import net.minecraft.scoreboard.ScoreCriteria;
import net.minecraft.scoreboard.Scoreboard;
import net.minecraft.scoreboard.Team;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.management.PlayerInteractionManager;
import net.minecraft.server.management.PlayerList;
import net.minecraft.stats.Stat;
import net.minecraft.stats.Stats;
import net.minecraft.util.CombatTracker;
@ -43,6 +58,7 @@ import net.minecraft.util.DamageSource;
import net.minecraft.util.FoodStats;
import net.minecraft.util.HandSide;
import net.minecraft.util.NonNullList;
import net.minecraft.util.Unit;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
@ -53,26 +69,38 @@ import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.event.HoverEvent;
import net.minecraft.world.GameRules;
import net.minecraft.world.GameType;
import net.minecraft.world.Teleporter;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.storage.WorldInfo;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.util.ITeleporter;
import net.minecraftforge.fml.hooks.BasicEventHooks;
import net.minecraftforge.fml.network.NetworkHooks;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.WeatherType;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.v.CraftServer;
import org.bukkit.craftbukkit.v.CraftWorld;
import org.bukkit.craftbukkit.v.entity.CraftPlayer;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.craftbukkit.v.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v.scoreboard.CraftScoreboardManager;
import org.bukkit.craftbukkit.v.util.BlockStateListPopulator;
import org.bukkit.craftbukkit.v.util.CraftChatMessage;
import org.bukkit.event.entity.EntityPotionEffectEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerChangedMainHandEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerLocaleChangeEvent;
import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.world.PortalCreateEvent;
import org.bukkit.inventory.MainHand;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@ -147,6 +175,250 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
this.maxHealthCache = this.getMaxHealth();
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite(remap = false)
@Nullable
public Entity changeDimension(DimensionType dim, ITeleporter teleporter) {
DimensionType[] destination = {dim};
if (this.isSleeping()) return (ServerPlayerEntity) (Object) this;
if (!ForgeHooks.onTravelToDimension((ServerPlayerEntity) (Object) this, destination[0])) return null;
PlayerTeleportEvent.TeleportCause cause = bridge$getTeleportCause().orElse(PlayerTeleportEvent.TeleportCause.UNKNOWN);
// this.invulnerableDimensionChange = true;
DimensionType dimensiontype = this.dimension;
if (((DimensionTypeBridge) dimensiontype).bridge$getType() == DimensionType.THE_END && ((DimensionTypeBridge) destination[0]).bridge$getType() == DimensionType.OVERWORLD && teleporter instanceof Teleporter) { //Forge: Fix non-vanilla teleporters triggering end credits
this.invulnerableDimensionChange = true;
this.detach();
this.getServerWorld().removePlayer((ServerPlayerEntity) (Object) this, true); //Forge: The player entity is cloned so keep the data until after cloning calls copyFrom
if (!this.queuedEndExit) {
this.queuedEndExit = true;
this.connection.sendPacket(new SChangeGameStatePacket(4, this.seenCredits ? 0.0F : 1.0F));
this.seenCredits = true;
}
return (ServerPlayerEntity) (Object) this;
} else {
ServerWorld serverworld = this.server.getWorld(dimensiontype);
// this.dimension = destination;
ServerWorld[] serverworld1 = {this.server.getWorld(destination[0])};
/*
WorldInfo worldinfo = serverworld1.getWorldInfo();
NetworkHooks.sendDimensionDataPacket(this.connection.netManager, (ServerPlayerEntity) (Object) this);
this.connection.sendPacket(new SRespawnPacket(destination, WorldInfo.byHashing(worldinfo.getSeed()), worldinfo.getGenerator(), this.interactionManager.getGameType()));
this.connection.sendPacket(new SServerDifficultyPacket(worldinfo.getDifficulty(), worldinfo.isDifficultyLocked()));
PlayerList playerlist = this.server.getPlayerList();
playerlist.updatePermissionLevel((ServerPlayerEntity) (Object) this);
serverworld.removeEntity((ServerPlayerEntity) (Object) this, true); //Forge: the player entity is moved to the new world, NOT cloned. So keep the data alive with no matching invalidate call.
this.revive();
*/
PlayerList[] playerlist = new PlayerList[1];
Entity e = teleporter.placeEntity((ServerPlayerEntity) (Object) this, serverworld, serverworld1[0], this.rotationYaw, spawnPortal -> {//Forge: Start vanilla logic
double d0 = this.getPosX();
double d1 = this.getPosY();
double d2 = this.getPosZ();
float f = this.rotationPitch;
float f1 = this.rotationYaw;
double d3 = 8.0D;
float f2 = f1;
serverworld.getProfiler().startSection("moving");
if (serverworld1[0] != null) {
double moveFactor = serverworld.getDimension().getMovementFactor() / serverworld1[0].getDimension().getMovementFactor();
d0 *= moveFactor;
d2 *= moveFactor;
if (dimensiontype == DimensionType.OVERWORLD && destination[0] == DimensionType.THE_NETHER) {
this.enteredNetherPosition = this.getPositionVec();
} else if (dimensiontype == DimensionType.OVERWORLD && destination[0] == DimensionType.THE_END) {
BlockPos blockpos = serverworld1[0].getSpawnCoordinate();
d0 = blockpos.getX();
d1 = blockpos.getY();
d2 = blockpos.getZ();
f1 = 90.0F;
f = 0.0F;
}
}
Location enter = this.bridge$getBukkitEntity().getLocation();
Location exit = (serverworld1[0] == null) ? null : new Location(((ServerWorldBridge) serverworld1[0]).bridge$getWorld(), d0, d1, d2, f1, f);
PlayerPortalEvent event = new PlayerPortalEvent(this.bridge$getBukkitEntity(), enter, exit, cause, 128, true, ((DimensionTypeBridge) destination[0]).bridge$getType() == DimensionType.THE_END ? 0 : 16);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled() || event.getTo() == null) {
return null;
}
exit = event.getTo();
if (exit == null) {
return null;
}
serverworld1[0] = ((CraftWorld) exit.getWorld()).getHandle();
d0 = exit.getX();
d1 = exit.getY();
d2 = exit.getZ();
// this.setLocationAndAngles(d0, d1, d2, f1, f);
serverworld.getProfiler().endSection();
serverworld.getProfiler().startSection("placing");
double d7 = Math.max(-2.9999872E7D, serverworld1[0].getWorldBorder().minX() + 16.0D);
double d4 = Math.max(-2.9999872E7D, serverworld1[0].getWorldBorder().minZ() + 16.0D);
double d5 = Math.min(2.9999872E7D, serverworld1[0].getWorldBorder().maxX() - 16.0D);
double d6 = Math.min(2.9999872E7D, serverworld1[0].getWorldBorder().maxZ() - 16.0D);
d0 = MathHelper.clamp(d0, d7, d5);
d2 = MathHelper.clamp(d2, d4, d6);
// this.setLocationAndAngles(d0, d1, d2, f1, f);
Vec3d exitVelocity = Vec3d.ZERO;
BlockPos exitPosition = new BlockPos(d0, d1, d2);
if (((DimensionTypeBridge) destination[0]).bridge$getType() == DimensionType.THE_END) {
int i = exitPosition.getX();
int j = exitPosition.getY() - 1;
int k = exitPosition.getZ();
if (event.getCanCreatePortal()) {
BlockStateListPopulator blockList = new BlockStateListPopulator(serverworld1[0]);
for (int j1 = -2; j1 <= 2; ++j1) {
for (int k1 = -2; k1 <= 2; ++k1) {
for (int l1 = -1; l1 < 3; ++l1) {
int i2 = i + k1 * 1 + j1 * 0;
int j2 = j + l1;
int k2 = k + k1 * 0 - j1 * 1;
boolean flag = l1 < 0;
blockList.setBlockState(new BlockPos(i2, j2, k2), flag ? Blocks.OBSIDIAN.getDefaultState() : Blocks.AIR.getDefaultState(), 3);
}
}
}
org.bukkit.World bworld = ((ServerWorldBridge) serverworld1[0]).bridge$getWorld();
PortalCreateEvent portalEvent = new PortalCreateEvent((List<BlockState>) (List) blockList.getList(), bworld, this.bridge$getBukkitEntity(), PortalCreateEvent.CreateReason.END_PLATFORM);
Bukkit.getPluginManager().callEvent(portalEvent);
if (!portalEvent.isCancelled()) {
blockList.updateList();
}
}
// this.setLocationAndAngles(i, j, k, f1, 0.0F);
exit.setX(i);
exit.setY(j);
exit.setZ(k);
// this.setMotion(Vec3d.ZERO);
exitVelocity = Vec3d.ZERO;
} else {
BlockPattern.PortalInfo portalInfo = ((TeleporterBridge) serverworld1[0].getDefaultTeleporter()).bridge$placeInPortal((ServerPlayerEntity) (Object) this, exitPosition, f2, event.getSearchRadius(), true);
if (spawnPortal && portalInfo == null && event.getCanCreatePortal()) {
if (((TeleporterBridge) serverworld1[0].getDefaultTeleporter()).bridge$makePortal((ServerPlayerEntity) (Object) this, exitPosition, event.getCreationRadius())) {
// serverworld1.getDefaultTeleporter().placeInPortal((ServerPlayerEntity) (Object) this, f2);
portalInfo = ((TeleporterBridge) serverworld1[0].getDefaultTeleporter()).bridge$placeInPortal((ServerPlayerEntity) (Object) this, exitPosition, f2, event.getSearchRadius(), true);
}
}
if (portalInfo == null) {
return null;
}
exitVelocity = portalInfo.motion;
exit.setX(portalInfo.pos.getX());
exit.setY(portalInfo.pos.getY());
exit.setZ(portalInfo.pos.getZ());
exit.setYaw(f2 + (float) portalInfo.rotation);
}
serverworld.getProfiler().endSection();
PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.bridge$getBukkitEntity(), enter, exit, cause);
Bukkit.getServer().getPluginManager().callEvent(tpEvent);
if (tpEvent.isCancelled() || tpEvent.getTo() == null) {
return null;
}
exit = tpEvent.getTo();
if (exit == null) {
return null;
}
serverworld1[0] = ((CraftWorld) exit.getWorld()).getHandle();
this.invulnerableDimensionChange = true;
destination[0] = serverworld1[0].getDimension().getType();
this.dimension = destination[0];
WorldInfo worldinfo = serverworld1[0].getWorldInfo();
NetworkHooks.sendDimensionDataPacket(this.connection.netManager, (ServerPlayerEntity) (Object) this);
this.connection.sendPacket(new SRespawnPacket(destination[0], WorldInfo.byHashing(worldinfo.getSeed()), worldinfo.getGenerator(), this.interactionManager.getGameType()));
this.connection.sendPacket(new SServerDifficultyPacket(worldinfo.getDifficulty(), worldinfo.isDifficultyLocked()));
playerlist[0] = this.server.getPlayerList();
playerlist[0].updatePermissionLevel((ServerPlayerEntity) (Object) this);
serverworld.removeEntity((ServerPlayerEntity) (Object) this, true); //Forge: the player entity is moved to the new world, NOT cloned. So keep the data alive with no matching invalidate call.
this.revive();
this.setMotion(exitVelocity);
this.setWorld(serverworld1[0]);
serverworld1[0].addDuringPortalTeleport((ServerPlayerEntity) (Object) this);
this.func_213846_b(serverworld);
// this.connection.setPlayerLocation(this.getPosX(), this.getPosY(), this.getPosZ(), f1, f);
((ServerPlayNetHandlerBridge) this.connection).bridge$teleport(exit);
this.connection.captureCurrentPosition();
return (ServerPlayerEntity) (Object) this;//forge: this is part of the ITeleporter patch
});//Forge: End vanilla logic
if (e == null) {
return (ServerPlayerEntity) (Object) this;
} else if (e != (Object) this) {
throw new IllegalArgumentException(String.format("Teleporter %s returned not the player entity but instead %s, expected PlayerEntity %s", teleporter, e, this));
}
this.interactionManager.setWorld(serverworld1[0]);
this.connection.sendPacket(new SPlayerAbilitiesPacket(this.abilities));
playerlist[0].sendWorldInfo((ServerPlayerEntity) (Object) this, serverworld1[0]);
playerlist[0].sendInventory((ServerPlayerEntity) (Object) this);
for (EffectInstance effectinstance : this.getActivePotionEffects()) {
this.connection.sendPacket(new SPlayEntityEffectPacket(this.getEntityId(), effectinstance));
}
this.connection.sendPacket(new SPlaySoundEventPacket(1032, BlockPos.ZERO, 0, false));
this.lastExperience = -1;
this.lastHealth = -1.0F;
this.lastFoodLevel = -1;
BasicEventHooks.firePlayerChangedDimensionEvent((ServerPlayerEntity) (Object) this, dimensiontype, destination[0]);
PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.bridge$getBukkitEntity(), ((WorldBridge) serverworld).bridge$getWorld());
Bukkit.getPluginManager().callEvent(changeEvent);
return (ServerPlayerEntity) (Object) this;
}
}
public Entity a(DimensionType dimensionmanager, final PlayerTeleportEvent.TeleportCause cause) {
bridge$pushChangeDimensionCause(cause);
return this.changeDimension(dimensionmanager);
}
@Override
public Either<PlayerEntity.SleepResult, Unit> sleep(BlockPos at, boolean force) {
return super.sleep(at, force).ifRight((p_213849_1_) -> {
this.addStat(Stats.SLEEP_IN_BED);
CriteriaTriggers.SLEPT_IN_BED.trigger((ServerPlayerEntity) (Object) this);
});
}
@Inject(method = "stopSleepInBed", cancellable = true, at = @At("HEAD"))
private void arclight$notWake(boolean flag, boolean flag1, CallbackInfo ci) {
if (!isSleeping()) ci.cancel();
}
@Override
public Entity bridge$changeDimension(DimensionType dimensionType, PlayerTeleportEvent.TeleportCause cause) {
return a(dimensionType, cause);
}
public BlockPos getSpawnPoint(ServerWorld worldserver) {
BlockPos blockposition = worldserver.getSpawnPoint();
if (worldserver.dimension.hasSkyLight() && worldserver.getWorldInfo().getGameType() != GameType.ADVENTURE) {
@ -313,7 +585,7 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
}
this.spawnShoulderEntities();
this.bridge$dropExperience();
this.dropExperience();
if (!event.getKeepInventory()) {
this.inventory.clear();
@ -325,7 +597,7 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
if (entityliving != null) {
this.addStat(Stats.ENTITY_KILLED_BY.get(entityliving.getType()));
entityliving.awardKillScore((ServerPlayerEntity) (Object) this, this.scoreValue, damagesource);
this.bridge$createWitherRose(entityliving);
this.createWitherRose(entityliving);
}
this.world.setEntityState((ServerPlayerEntity) (Object) this, (byte) 3);

View File

@ -251,7 +251,7 @@ public abstract class EnchantmentContainerMixin extends ContainerMixin implement
this.tableInventory.markDirty();
this.xpSeed.set(playerIn.getXPSeed());
this.onCraftMatrixChanged(this.tableInventory);
p_217003_6_.playSound((PlayerEntity) null, p_217003_7_, SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.BLOCKS, 1.0F, p_217003_6_.rand.nextFloat() * 0.1F + 0.9F);
p_217003_6_.playSound(null, p_217003_7_, SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.BLOCKS, 1.0F, p_217003_6_.rand.nextFloat() * 0.1F + 0.9F);
}
});

View File

@ -1,7 +1,6 @@
package io.izzel.arclight.common.mixin.core.item;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import io.izzel.arclight.common.bridge.item.BlockItemBridge;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
@ -21,7 +20,7 @@ import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(BlockItem.class)
public abstract class BlockItemMixin implements BlockItemBridge {
public abstract class BlockItemMixin {
// @formatter:off
@Shadow protected abstract boolean checkPosition();
@ -48,7 +47,7 @@ public abstract class BlockItemMixin implements BlockItemBridge {
protected boolean canPlace(BlockItemUseContext context, BlockState state) {
PlayerEntity playerentity = context.getPlayer();
ISelectionContext iselectioncontext = playerentity == null ? ISelectionContext.dummy() : ISelectionContext.forEntity(playerentity);
boolean original = (!this.checkPosition() || state.isValidPosition(context.getWorld(), context.getPos())) && this.bridge$noCollisionInSel(context.getWorld(), state, context.getPos(), iselectioncontext);
boolean original = (!this.checkPosition() || state.isValidPosition(context.getWorld(), context.getPos())) && context.getWorld().func_226663_a_(state, context.getPos(), iselectioncontext);
Player player = (context.getPlayer() instanceof ServerPlayerEntityBridge) ? ((ServerPlayerEntityBridge) context.getPlayer()).bridge$getBukkitEntity() : null;
BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(context.getWorld(), context.getPos()), player, CraftBlockData.fromData(state), original);

View File

@ -57,7 +57,7 @@ public class BoatItemMixin extends Item {
Vec3d vec3d1 = playerIn.getEyePosition(1.0F);
for (Entity entity : list) {
AxisAlignedBB axisalignedbb = entity.getBoundingBox().grow((double) entity.getCollisionBorderSize());
AxisAlignedBB axisalignedbb = entity.getBoundingBox().grow(entity.getCollisionBorderSize());
if (axisalignedbb.contains(vec3d1)) {
return new ActionResult<>(ActionResultType.PASS, itemstack);
}

View File

@ -105,7 +105,7 @@ public abstract class BowItemMixin extends ShootableItem {
}
}
worldIn.playSound((PlayerEntity) null, playerentity.posX, playerentity.posY, playerentity.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (random.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
worldIn.playSound(null, playerentity.posX, playerentity.posY, playerentity.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (random.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (!flag1 && !playerentity.abilities.isCreativeMode) {
itemstack.shrink(1);
if (itemstack.isEmpty()) {

View File

@ -39,7 +39,7 @@ public class ChorusFruitItemMixin extends Item {
for (int i = 0; i < 16; ++i) {
double d3 = entityLiving.posX + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
double d4 = MathHelper.clamp(entityLiving.posY + (double) (entityLiving.getRNG().nextInt(16) - 8), 0.0D, (double) (worldIn.getActualHeight() - 1));
double d4 = MathHelper.clamp(entityLiving.posY + (double) (entityLiving.getRNG().nextInt(16) - 8), 0.0D, worldIn.getActualHeight() - 1);
double d5 = entityLiving.posZ + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
if (entityLiving instanceof ServerPlayerEntity) {
@ -59,7 +59,7 @@ public class ChorusFruitItemMixin extends Item {
}
if (entityLiving.attemptTeleport(d3, d4, d5, true)) {
worldIn.playSound((PlayerEntity) null, d0, d1, d2, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
worldIn.playSound(null, d0, d1, d2, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
entityLiving.playSound(SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, 1.0F, 1.0F);
break;
}

View File

@ -43,7 +43,7 @@ public class EnderPearlItemMixin extends Item {
}
}
worldIn.playSound((PlayerEntity) null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
playerIn.getCooldownTracker().setCooldown(this, 20);
playerIn.addStat(Stats.ITEM_USED.get(this));

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.item;
package io.izzel.arclight.common.mixin.core.item;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge;
@ -21,7 +21,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@Mixin(LeadItem.class)
public class LeadItemMixin_1_15 {
public class LeadItemMixin {
/**
* @author IzzelAliz

View File

@ -76,7 +76,7 @@ public abstract class RecipeManagerMixin implements RecipeManagerBridge {
}
this.recipes = (Map) map;
LOGGER.info("Loaded {} recipes", (int) map.size());
LOGGER.info("Loaded {} recipes", map.size());
}
/**

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.item.crafting;
package io.izzel.arclight.common.mixin.core.item.crafting;
import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge;
import net.minecraft.item.crafting.SpecialRecipe;

View File

@ -38,6 +38,7 @@ import net.minecraft.item.Items;
import net.minecraft.item.WritableBookItem;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.StringNBT;
import net.minecraft.network.IPacket;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.PacketThreadUtil;
@ -309,7 +310,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
this.netManager.sendPacket(new SMoveVehiclePacket(entity));
return;
}
boolean flag = this.bridge$worldNoCollision(worldserver, entity, entity.getBoundingBox().shrink(0.0625));
boolean flag = worldserver.hasNoCollisions(entity, entity.getBoundingBox().shrink(0.0625));
d7 = d4 - this.lowestRiddenX1;
d8 = d5 - this.lowestRiddenY1 - 1.0E-6;
d9 = d6 - this.lowestRiddenZ1;
@ -329,7 +330,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
}
entity.setPositionAndRotation(d4, d5, d6, f, f2);
this.player.setPositionAndRotation(d4, d5, d6, this.player.rotationYaw, this.player.rotationPitch);
boolean flag3 = this.bridge$worldNoCollision(worldserver, entity, entity.getBoundingBox().shrink(0.0625));
boolean flag3 = worldserver.hasNoCollisions(entity, entity.getBoundingBox().shrink(0.0625));
if (flag && (flag2 || !flag3)) {
entity.setPositionAndRotation(d0, d2, d3, f, f2);
this.player.setPositionAndRotation(d0, d2, d3, this.player.rotationYaw, this.player.rotationPitch);
@ -421,14 +422,14 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
if (nbttagcompound != null) {
itemstack3.setTag(nbttagcompound.copy());
}
itemstack3.setTagInfo("author", this.bridge$stringNbt(this.player.getName().getString()));
itemstack3.setTagInfo("title", this.bridge$stringNbt(itemstack.getTag().getString("title")));
itemstack3.setTagInfo("author", StringNBT.valueOf(this.player.getName().getString()));
itemstack3.setTagInfo("title", StringNBT.valueOf(itemstack.getTag().getString("title")));
ListNBT nbttaglist = itemstack.getTag().getList("pages", 8);
for (int i = 0; i < nbttaglist.size(); ++i) {
String s = nbttaglist.getString(i);
StringTextComponent chatcomponenttext = new StringTextComponent(s);
s = ITextComponent.Serializer.toJson(chatcomponenttext);
nbttaglist.set(i, this.bridge$stringNbt(s));
nbttaglist.set(i, StringNBT.valueOf(s));
}
itemstack3.setTagInfo("pages", nbttaglist);
this.player.setHeldItem(packetplayinbedit.getHand(), CraftEventFactory.handleEditBookEvent(this.player, enumitemslot, itemstack2, itemstack3));
@ -688,13 +689,13 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
return;
}
}
this.bridge$dropItems(this.player, false);
this.player.drop(false);
}
return;
}
case DROP_ALL_ITEMS: {
if (!this.player.isSpectator()) {
this.bridge$dropItems(this.player, true);
this.player.drop(true);
}
return;
}
@ -778,7 +779,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
float f8 = f3 * f5;
double d4 = (this.player.interactionManager.getGameType() == GameType.CREATIVE) ? 5.0 : 4.5;
Vec3d vec3d2 = vec3d.add(f7 * d4, f6 * d4, f8 * d4);
RayTraceResult movingobjectposition = this.player.world.rayTraceBlocks(new RayTraceContext(vec3d, vec3d2, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, this.player));
BlockRayTraceResult movingobjectposition = this.player.world.rayTraceBlocks(new RayTraceContext(vec3d, vec3d2, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, this.player));
boolean cancelled;
if (movingobjectposition == null || movingobjectposition.getType() != RayTraceResult.Type.BLOCK) {
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand);
@ -787,7 +788,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
((PlayerInteractionManagerBridge) this.player.interactionManager).bridge$setFiredInteract(false);
cancelled = ((PlayerInteractionManagerBridge) this.player.interactionManager).bridge$getInteractResult();
} else {
BlockRayTraceResult movingobjectpositionblock = (BlockRayTraceResult) movingobjectposition;
BlockRayTraceResult movingobjectpositionblock = movingobjectposition;
PlayerInteractEvent event2 = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getPos(), movingobjectpositionblock.getFace(), itemstack, true, enumhand);
cancelled = (event2.useItemInHand() == Event.Result.DENY);
}

View File

@ -1,23 +1,34 @@
package io.izzel.arclight.common.mixin.core.server.management;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import io.izzel.arclight.common.bridge.server.management.PlayerInteractionManagerBridge;
import io.izzel.arclight.common.mod.ArclightMod;
import io.izzel.arclight.common.mod.util.ArclightCaptures;
import net.minecraft.block.BlockState;
import net.minecraft.block.CakeBlock;
import net.minecraft.block.DoorBlock;
import net.minecraft.block.TrapDoorBlock;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.network.play.client.CPlayerDiggingPacket;
import net.minecraft.network.play.server.SChangeBlockPacket;
import net.minecraft.network.play.server.SPlayerDiggingPacket;
import net.minecraft.server.management.PlayerInteractionManager;
import net.minecraft.state.properties.DoubleBlockHalf;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.GameType;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.ForgeHooks;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.Event;
@ -51,6 +62,7 @@ public abstract class PlayerInteractionManagerMixin implements PlayerInteraction
@Shadow private boolean receivedFinishDiggingPacket;
@Shadow private BlockPos delayedDestroyPos;
@Shadow private int initialBlockDamage;
@Shadow public abstract void func_229860_a_(BlockPos p_229860_1_, CPlayerDiggingPacket.Action p_229860_2_, String p_229860_3_);
// @formatter:on
public boolean interactResult = false;
@ -70,18 +82,18 @@ public abstract class PlayerInteractionManagerMixin implements PlayerInteraction
dist *= dist;
net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock forgeEvent = net.minecraftforge.common.ForgeHooks.onLeftClickBlock(player, blockPos, direction);
if (forgeEvent.isCanceled() || (!this.isCreative() && forgeEvent.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY)) { // Restore block and te data
player.connection.sendPacket(this.bridge$diggingPacket(blockPos, world.getBlockState(blockPos), action, false, "mod canceled"));
player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, world.getBlockState(blockPos), action, false, "mod canceled"));
world.notifyBlockUpdate(blockPos, world.getBlockState(blockPos), world.getBlockState(blockPos), 3);
return;
}
if (d4 > dist) {
this.player.connection.sendPacket(this.bridge$diggingPacket(blockPos, this.world.getBlockState(blockPos), action, false, "too far"));
this.player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, this.world.getBlockState(blockPos), action, false, "too far"));
} else if (blockPos.getY() >= i) {
this.player.connection.sendPacket(this.bridge$diggingPacket(blockPos, this.world.getBlockState(blockPos), action, false, "too high"));
this.player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, this.world.getBlockState(blockPos), action, false, "too high"));
} else if (action == CPlayerDiggingPacket.Action.START_DESTROY_BLOCK) {
if (!this.world.isBlockModifiable(this.player, blockPos)) {
CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockPos, direction, this.player.inventory.getCurrentItem(), Hand.MAIN_HAND);
this.player.connection.sendPacket(this.bridge$diggingPacket(blockPos, this.world.getBlockState(blockPos), action, false, "may not interact"));
this.player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, this.world.getBlockState(blockPos), action, false, "may not interact"));
TileEntity tileentity = this.world.getTileEntity(blockPos);
if (tileentity != null) {
this.player.connection.sendPacket(tileentity.getUpdatePacket());
@ -99,14 +111,14 @@ public abstract class PlayerInteractionManagerMixin implements PlayerInteraction
}
if (this.isCreative()) {
if (!this.world.extinguishFire(null, blockPos, direction)) {
this.bridge$creativeHarvestBlock(blockPos, action, "creative destroy");
this.func_229860_a_(blockPos, action, "creative destroy");
} else {
this.player.connection.sendPacket(this.bridge$diggingPacket(blockPos, this.world.getBlockState(blockPos), action, true, "fire put out"));
this.player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, this.world.getBlockState(blockPos), action, true, "fire put out"));
}
return;
}
if (this.player.blockActionRestricted(this.world, blockPos, this.gameType)) {
this.player.connection.sendPacket(this.bridge$diggingPacket(blockPos, this.world.getBlockState(blockPos), action, false, "block action restricted"));
this.player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, this.world.getBlockState(blockPos), action, false, "block action restricted"));
return;
}
this.initialDamage = this.ticks;
@ -143,16 +155,16 @@ public abstract class PlayerInteractionManagerMixin implements PlayerInteraction
f = 2.0f;
}
if (!iblockdata.isAir() && f >= 1.0f) {
this.bridge$creativeHarvestBlock(blockPos, action, "insta mine");
this.func_229860_a_(blockPos, action, "insta mine");
} else {
if (this.isDestroyingBlock) {
this.player.connection.sendPacket(this.bridge$diggingPacket(this.destroyPos, this.world.getBlockState(this.destroyPos), CPlayerDiggingPacket.Action.START_DESTROY_BLOCK, false, "abort destroying since another started (client insta mine, server disagreed)"));
this.player.connection.sendPacket(new SPlayerDiggingPacket(this.destroyPos, this.world.getBlockState(this.destroyPos), CPlayerDiggingPacket.Action.START_DESTROY_BLOCK, false, "abort destroying since another started (client insta mine, server disagreed)"));
}
this.isDestroyingBlock = true;
this.destroyPos = blockPos;
int j = (int) (f * 10.0f);
this.world.sendBlockBreakProgress(this.player.getEntityId(), blockPos, j);
this.player.connection.sendPacket(this.bridge$diggingPacket(blockPos, this.world.getBlockState(blockPos), action, true, "actual start of destroying"));
this.player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, this.world.getBlockState(blockPos), action, true, "actual start of destroying"));
this.durabilityRemainingOnBlock = j;
}
} else if (action == CPlayerDiggingPacket.Action.STOP_DESTROY_BLOCK) {
@ -164,7 +176,7 @@ public abstract class PlayerInteractionManagerMixin implements PlayerInteraction
if (f2 >= 0.7f) {
this.isDestroyingBlock = false;
this.world.sendBlockBreakProgress(this.player.getEntityId(), blockPos, -1);
this.bridge$creativeHarvestBlock(blockPos, action, "destroyed");
this.func_229860_a_(blockPos, action, "destroyed");
return;
}
if (!this.receivedFinishDiggingPacket) {
@ -175,16 +187,16 @@ public abstract class PlayerInteractionManagerMixin implements PlayerInteraction
}
}
}
this.player.connection.sendPacket(this.bridge$diggingPacket(blockPos, this.world.getBlockState(blockPos), action, true, "stopped destroying"));
this.player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, this.world.getBlockState(blockPos), action, true, "stopped destroying"));
} else if (action == CPlayerDiggingPacket.Action.ABORT_DESTROY_BLOCK) {
this.isDestroyingBlock = false;
if (!Objects.equals(this.destroyPos, blockPos)) {
ArclightMod.LOGGER.debug("Mismatch in destroy block pos: " + this.destroyPos + " " + blockPos);
this.world.sendBlockBreakProgress(this.player.getEntityId(), this.destroyPos, -1);
this.player.connection.sendPacket(this.bridge$diggingPacket(this.destroyPos, this.world.getBlockState(this.destroyPos), action, true, "aborted mismatched destroying"));
this.player.connection.sendPacket(new SPlayerDiggingPacket(this.destroyPos, this.world.getBlockState(this.destroyPos), action, true, "aborted mismatched destroying"));
}
this.world.sendBlockBreakProgress(this.player.getEntityId(), blockPos, -1);
this.player.connection.sendPacket(this.bridge$diggingPacket(blockPos, this.world.getBlockState(blockPos), action, true, "aborted destroying"));
this.player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, this.world.getBlockState(blockPos), action, true, "aborted destroying"));
}
}
@ -218,4 +230,77 @@ public abstract class PlayerInteractionManagerMixin implements PlayerInteraction
public void bridge$setInteractResult(boolean b) {
this.interactResult = b;
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public ActionResultType func_219441_a(PlayerEntity playerIn, World worldIn, ItemStack stackIn, Hand handIn, BlockRayTraceResult blockRaytraceResultIn) {
BlockPos blockpos = blockRaytraceResultIn.getPos();
BlockState blockstate = worldIn.getBlockState(blockpos);
ActionResultType resultType = ActionResultType.PASS;
boolean cancelledBlock = false;
if (this.gameType == GameType.SPECTATOR) {
INamedContainerProvider provider = blockstate.getContainer(worldIn, blockpos);
cancelledBlock = !(provider instanceof INamedContainerProvider);
}
if (playerIn.getCooldownTracker().hasCooldown(stackIn.getItem())) {
cancelledBlock = true;
}
PlayerInteractEvent bukkitEvent = CraftEventFactory.callPlayerInteractEvent(playerIn, Action.RIGHT_CLICK_BLOCK, blockpos, blockRaytraceResultIn.getFace(), stackIn, cancelledBlock, handIn);
bridge$setFiredInteract(true);
bridge$setInteractResult(bukkitEvent.useItemInHand() == Event.Result.DENY);
if (bukkitEvent.useInteractedBlock() == Event.Result.DENY) {
if (blockstate.getBlock() instanceof DoorBlock) {
boolean bottom = blockstate.get(DoorBlock.HALF) == DoubleBlockHalf.LOWER;
((ServerPlayerEntity) playerIn).connection.sendPacket(new SChangeBlockPacket(this.world, bottom ? blockpos.up() : blockpos.down()));
} else if (blockstate.getBlock() instanceof CakeBlock) {
((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity().sendHealthUpdate();
}
((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity().updateInventory();
resultType = ((bukkitEvent.useItemInHand() != Event.Result.ALLOW) ? ActionResultType.SUCCESS : ActionResultType.PASS);
} else if (this.gameType == GameType.SPECTATOR) {
INamedContainerProvider inamedcontainerprovider = blockstate.getContainer(worldIn, blockpos);
if (inamedcontainerprovider != null) {
playerIn.openContainer(inamedcontainerprovider);
return ActionResultType.SUCCESS;
} else {
return ActionResultType.PASS;
}
} else {
net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock event = ForgeHooks.onRightClickBlock(playerIn, handIn, blockpos, blockRaytraceResultIn.getFace());
if (event.isCanceled()) return event.getCancellationResult();
ItemUseContext itemusecontext = new ItemUseContext(playerIn, handIn, blockRaytraceResultIn);
if (event.getUseItem() != net.minecraftforge.eventbus.api.Event.Result.DENY) {
ActionResultType result = stackIn.onItemUseFirst(itemusecontext);
if (result != ActionResultType.PASS) return result;
}
boolean flag = !playerIn.getHeldItemMainhand().isEmpty() || !playerIn.getHeldItemOffhand().isEmpty();
boolean flag1 = (playerIn.isSecondaryUseActive() && flag) && !(playerIn.getHeldItemMainhand().doesSneakBypassUse(worldIn, blockpos, playerIn) && playerIn.getHeldItemOffhand().doesSneakBypassUse(worldIn, blockpos, playerIn));
if (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY && !flag1) {
resultType = blockstate.onBlockActivated(worldIn, playerIn, handIn, blockRaytraceResultIn);
if (resultType.isSuccessOrConsume()) {
return resultType;
}
}
if (!stackIn.isEmpty() && resultType != ActionResultType.SUCCESS && !bridge$getInteractResult()) {
if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) {
return ActionResultType.PASS;
}
if (this.isCreative()) {
int i = stackIn.getCount();
resultType = stackIn.onItemUse(itemusecontext);
stackIn.setCount(i);
return resultType;
} else {
return stackIn.onItemUse(itemusecontext);
}
} else {
return resultType;
}
}
return resultType;
}
}

View File

@ -27,7 +27,9 @@ import net.minecraft.network.login.ServerLoginNetHandler;
import net.minecraft.network.play.server.SChangeGameStatePacket;
import net.minecraft.network.play.server.SChatPacket;
import net.minecraft.network.play.server.SEntityStatusPacket;
import net.minecraft.network.play.server.SJoinGamePacket;
import net.minecraft.network.play.server.SPlayEntityEffectPacket;
import net.minecraft.network.play.server.SRespawnPacket;
import net.minecraft.network.play.server.SServerDifficultyPacket;
import net.minecraft.network.play.server.SSetExperiencePacket;
import net.minecraft.network.play.server.SSpawnPositionPacket;
@ -48,8 +50,10 @@ import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.GameRules;
import net.minecraft.world.GameType;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.WorldType;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.storage.IPlayerFileData;
@ -151,6 +155,11 @@ public abstract class PlayerListMixin implements PlayerListBridge {
((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity().sendSupportedChannels();
}
@Redirect(method = "initializeConnectionToPlayer", at = @At(value = "NEW", target = "net/minecraft/network/play/server/SJoinGamePacket"))
private SJoinGamePacket arclight$spawnPacket(int playerId, GameType gameType, long hashedSeed, boolean hardcoreMode, DimensionType dimensionType, int maxPlayers, WorldType worldType, int viewDistance, boolean reducedDebugInfo, boolean enableRespawnScreen, NetworkManager netManager, ServerPlayerEntity playerIn) {
return new SJoinGamePacket(playerId, gameType, hashedSeed, hardcoreMode, ((DimensionTypeBridge) dimensionType).bridge$getType(), maxPlayers, worldType, ((ServerWorldBridge) playerIn.getServerWorld()).bridge$spigotConfig().viewDistance, reducedDebugInfo, enableRespawnScreen);
}
@Inject(method = "func_212504_a", cancellable = true, at = @At("HEAD"))
private void arclight$returnIfSet(ServerWorld world, CallbackInfo ci) {
if (this.playerDataManager != null) {
@ -240,7 +249,7 @@ public abstract class PlayerListMixin implements PlayerListBridge {
isBedSpawn = true;
location = new Location(cworld, vec3d.x, vec3d.y, vec3d.z);
} else {
this.bridge$setSpawnPoint(playerIn, null, true, playerIn.dimension, false);
playerIn.setSpawnPoint(null, true, false, playerIn.dimension);
playerIn.connection.sendPacket(new SChangeGameStatePacket(0, 0.0f));
}
}
@ -269,11 +278,11 @@ public abstract class PlayerListMixin implements PlayerListBridge {
playerIn.setPosition(playerIn.getPosX(), playerIn.getPosY() + 1.0, playerIn.getPosZ());
}
if (fromWorld.getEnvironment() == ((WorldBridge) serverWorld).bridge$getWorld().getEnvironment()) {
playerIn.connection.sendPacket(this.bridge$respawnPacket((serverWorld.dimension.getType().getId() >= 0) ? DimensionType.THE_NETHER : DimensionType.OVERWORLD, serverWorld.getWorldInfo().getSeed(), serverWorld.getWorldInfo().getGenerator(), playerIn.interactionManager.getGameType()));
playerIn.connection.sendPacket(new SRespawnPacket((serverWorld.dimension.getType().getId() >= 0) ? DimensionType.THE_NETHER : DimensionType.OVERWORLD, WorldInfo.byHashing(serverWorld.getWorldInfo().getSeed()), serverWorld.getWorldInfo().getGenerator(), playerIn.interactionManager.getGameType()));
}
WorldInfo worldInfo = serverWorld.getWorldInfo();
net.minecraftforge.fml.network.NetworkHooks.sendDimensionDataPacket(playerIn.connection.netManager, playerIn);
playerIn.connection.sendPacket(this.bridge$respawnPacket(((DimensionTypeBridge) serverWorld.dimension.getType()).bridge$getType(), serverWorld.getWorldInfo().getSeed(), serverWorld.getWorldInfo().getGenerator(), playerIn.interactionManager.getGameType()));
playerIn.connection.sendPacket(new SRespawnPacket(((DimensionTypeBridge) serverWorld.dimension.getType()).bridge$getType(), WorldInfo.byHashing(serverWorld.getWorldInfo().getSeed()), serverWorld.getWorldInfo().getGenerator(), playerIn.interactionManager.getGameType()));
playerIn.connection.sendPacket(new SUpdateViewDistancePacket(((ServerWorldBridge) serverWorld).bridge$spigotConfig().viewDistance));
playerIn.setWorld(serverWorld);
playerIn.interactionManager.setWorld(serverWorld);
@ -359,7 +368,7 @@ public abstract class PlayerListMixin implements PlayerListBridge {
isBedSpawn = true;
location = new Location(cworld, vec3d.x, vec3d.y, vec3d.z);
} else {
this.bridge$setSpawnPoint(playerIn, null, true, playerIn.dimension, false);
playerIn.setSpawnPoint(null, true, false, playerIn.dimension);
playerIn.connection.sendPacket(new SChangeGameStatePacket(0, 0.0f));
}
}
@ -414,17 +423,17 @@ public abstract class PlayerListMixin implements PlayerListBridge {
this.setPlayerGameTypeBasedOnOther(serverplayerentity, playerIn, serverworld);
while (avoidSuffocation && !this.bridge$worldNoCollision(serverworld, serverplayerentity) && serverplayerentity.posY < 256.0D) {
while (avoidSuffocation && !serverworld.hasNoCollisions(serverplayerentity) && serverplayerentity.posY < 256.0D) {
serverplayerentity.setPosition(serverplayerentity.posX, serverplayerentity.posY + 1.0D, serverplayerentity.posZ);
}
if (fromWorld.getEnvironment() == ((WorldBridge) serverworld).bridge$getWorld().getEnvironment()) {
serverplayerentity.connection.sendPacket(this.bridge$respawnPacket((((DimensionTypeBridge) serverplayerentity.dimension).bridge$getType().getId() >= 0) ? DimensionType.THE_NETHER : DimensionType.OVERWORLD, serverworld.getWorldInfo().getSeed(), serverworld.getWorldInfo().getGenerator(), playerIn.interactionManager.getGameType()));
serverplayerentity.connection.sendPacket(new SRespawnPacket((((DimensionTypeBridge) serverplayerentity.dimension).bridge$getType().getId() >= 0) ? DimensionType.THE_NETHER : DimensionType.OVERWORLD, WorldInfo.byHashing(serverworld.getWorldInfo().getSeed()), serverworld.getWorldInfo().getGenerator(), playerIn.interactionManager.getGameType()));
}
WorldInfo worldinfo = serverplayerentity.world.getWorldInfo();
NetworkHooks.sendDimensionDataPacket(serverplayerentity.connection.netManager, serverplayerentity);
serverplayerentity.connection.sendPacket(this.bridge$respawnPacket(((DimensionTypeBridge) serverplayerentity.dimension).bridge$getType(), worldinfo.getSeed(), worldinfo.getGenerator(), serverplayerentity.interactionManager.getGameType()));
serverplayerentity.connection.sendPacket(new SRespawnPacket(((DimensionTypeBridge) serverplayerentity.dimension).bridge$getType(), WorldInfo.byHashing(worldinfo.getSeed()), worldinfo.getGenerator(), serverplayerentity.interactionManager.getGameType()));
serverplayerentity.connection.sendPacket(new SUpdateViewDistancePacket(((WorldBridge) serverworld).bridge$spigotConfig().viewDistance));
BlockPos blockpos1 = serverworld.getSpawnPoint();
serverplayerentity.connection.setPlayerLocation(serverplayerentity.posX, serverplayerentity.posY, serverplayerentity.posZ, serverplayerentity.rotationYaw, serverplayerentity.rotationPitch);
@ -456,7 +465,7 @@ public abstract class PlayerListMixin implements PlayerListBridge {
public void sendAll(IPacket<?> packet, PlayerEntity entityhuman) {
for (ServerPlayerEntity entityplayer : this.players) {
if (entityhuman == null || !(entityhuman instanceof ServerPlayerEntity) || ((ServerPlayerEntityBridge) entityplayer).bridge$getBukkitEntity().canSee(((ServerPlayerEntityBridge) entityhuman).bridge$getBukkitEntity())) {
if (!(entityhuman instanceof ServerPlayerEntity) || ((ServerPlayerEntityBridge) entityplayer).bridge$getBukkitEntity().canSee(((ServerPlayerEntityBridge) entityhuman).bridge$getBukkitEntity())) {
entityplayer.connection.sendPacket(packet);
}
}

View File

@ -1,9 +1,8 @@
package io.izzel.arclight.common.mixin.v1_15.tileentity;
package io.izzel.arclight.common.mixin.core.tileentity;
import com.google.common.collect.Lists;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.common.mixin.core.tileentity.TileEntityMixin;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;

View File

@ -2,10 +2,14 @@ package io.izzel.arclight.common.mixin.core.world;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.mojang.datafixers.util.Pair;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.world.ExplosionBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.enchantment.ProtectionEnchantment;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
@ -14,17 +18,26 @@ import net.minecraft.entity.item.TNTEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.DamagingProjectileEntity;
import net.minecraft.fluid.IFluidState;
import net.minecraft.item.ItemStack;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootParameters;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@ -37,8 +50,10 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
@Mixin(Explosion.class)
@ -59,6 +74,9 @@ public abstract class ExplosionMixin implements ExplosionBridge {
@Accessor("size") public abstract float bridge$getSize();
@Accessor("size") public abstract void bridge$setSize(float size);
@Accessor("mode") public abstract Explosion.Mode bridge$getMode();
@Shadow @Final private boolean causesFire;
@Shadow @Final private Random random;
@Shadow private static void func_229976_a_(ObjectArrayList<Pair<ItemStack, BlockPos>> p_229976_0_, ItemStack p_229976_1_, BlockPos p_229976_2_) { }
// @formatter:on
@Inject(method = "<init>(Lnet/minecraft/world/World;Lnet/minecraft/entity/Entity;DDDFZLnet/minecraft/world/Explosion$Mode;)V",
@ -135,7 +153,7 @@ public abstract class ExplosionMixin implements ExplosionBridge {
double d12 = MathHelper.sqrt(entity.getDistanceSq(vec3d)) / f3;
if (d12 <= 1.0D) {
double d5 = entity.posX - this.x;
double d7 = ((EntityBridge) entity).bridge$getEyeHeight() - this.y;
double d7 = entity.getPosYEye() - this.y;
double d9 = entity.posZ - this.z;
double d13 = MathHelper.sqrt(d5 * d5 + d7 * d7 + d9 * d9);
if (d13 != 0.0D) {
@ -172,8 +190,89 @@ public abstract class ExplosionMixin implements ExplosionBridge {
}
public boolean wasCanceled = false;
@Override
public float bridge$callBlockExplodeEvent() {
public boolean bridge$wasCancelled() {
return wasCanceled;
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public void doExplosionB(boolean spawnParticles) {
if (this.world.isRemote) {
this.world.playSound(this.x, this.y, this.z, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, (1.0F + (this.world.rand.nextFloat() - this.world.rand.nextFloat()) * 0.2F) * 0.7F, false);
}
boolean flag = this.mode != Explosion.Mode.NONE;
if (spawnParticles) {
if (!(this.size < 2.0F) && flag) {
this.world.addParticle(ParticleTypes.EXPLOSION_EMITTER, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D);
} else {
this.world.addParticle(ParticleTypes.EXPLOSION, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D);
}
}
if (flag) {
ObjectArrayList<Pair<ItemStack, BlockPos>> objectarraylist = new ObjectArrayList<>();
Collections.shuffle(this.affectedBlockPositions, this.world.rand);
float yield = this.callBlockExplodeEvent();
if (Float.isNaN(yield)) {
this.wasCanceled = true;
return;
}
for (BlockPos blockpos : this.affectedBlockPositions) {
BlockState blockstate = this.world.getBlockState(blockpos);
Block block = blockstate.getBlock();
if (!blockstate.isAir(this.world, blockpos)) {
BlockPos blockpos1 = blockpos.toImmutable();
this.world.getProfiler().startSection("explosion_blocks");
if (blockstate.canDropFromExplosion(this.world, blockpos, (Explosion) (Object) this) && this.world instanceof ServerWorld) {
TileEntity tileentity = blockstate.hasTileEntity() ? this.world.getTileEntity(blockpos) : null;
LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld) this.world)).withRandom(this.world.rand).withParameter(LootParameters.POSITION, blockpos).withParameter(LootParameters.TOOL, ItemStack.EMPTY).withNullableParameter(LootParameters.BLOCK_ENTITY, tileentity).withNullableParameter(LootParameters.THIS_ENTITY, this.exploder);
if (this.mode == Explosion.Mode.DESTROY || yield < 1.0F) {
lootcontext$builder.withParameter(LootParameters.EXPLOSION_RADIUS, 1.0F / yield);
}
blockstate.getDrops(lootcontext$builder).forEach((p_229977_2_) -> {
func_229976_a_(objectarraylist, p_229977_2_, blockpos1);
});
}
blockstate.onBlockExploded(this.world, blockpos, (Explosion) (Object) this);
this.world.getProfiler().endSection();
}
}
for (Pair<ItemStack, BlockPos> pair : objectarraylist) {
Block.spawnAsEntity(this.world, pair.getSecond(), pair.getFirst());
}
}
if (this.causesFire) {
for (BlockPos blockpos2 : this.affectedBlockPositions) {
if (this.random.nextInt(3) == 0 && this.world.getBlockState(blockpos2).isAir() && this.world.getBlockState(blockpos2.down()).isOpaqueCube(this.world, blockpos2.down())) {
BlockIgniteEvent event = CraftEventFactory.callBlockIgniteEvent(this.world, blockpos2.getX(), blockpos2.getY(), blockpos2.getZ(), (Explosion) (Object) this);
if (!event.isCancelled()) {
this.world.setBlockState(blockpos2, Blocks.FIRE.getDefaultState());
}
}
}
}
}
@Inject(method = "func_229976_a_", cancellable = true, at = @At("HEAD"))
private static void arclight$fix(ObjectArrayList<Pair<ItemStack, BlockPos>> p_229976_0_, ItemStack stack, BlockPos p_229976_2_, CallbackInfo ci) {
if (stack.isEmpty()) ci.cancel();
}
private float callBlockExplodeEvent() {
org.bukkit.World world = ((WorldBridge) this.world).bridge$getWorld();
org.bukkit.entity.Entity exploder = this.exploder == null ? null : ((EntityBridge) this.exploder).bridge$getBukkitEntity();
Location location = new Location(world, this.x, this.y, this.z);

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.world;
package io.izzel.arclight.common.mixin.core.world;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.world.TeleporterBridge;
@ -38,7 +38,7 @@ import java.util.Random;
import java.util.stream.Collectors;
@Mixin(Teleporter.class)
public abstract class TeleporterMixin_1_15 implements TeleporterBridge {
public abstract class TeleporterMixin implements TeleporterBridge {
// @formatter:off
@Shadow @Final protected ServerWorld world;

View File

@ -3,6 +3,7 @@ package io.izzel.arclight.common.mixin.core.world;
import io.izzel.arclight.api.ArclightVersion;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.common.bridge.world.border.WorldBorderBridge;
import io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge;
import io.izzel.arclight.common.bridge.world.storage.DerivedWorldInfoBridge;
import io.izzel.arclight.common.mod.util.ArclightCaptures;
import net.minecraft.block.Block;
@ -35,6 +36,7 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@ -176,6 +178,11 @@ public abstract class WorldMixin implements WorldBridge {
}
}
@Redirect(method = "isNightTime", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/dimension/Dimension;getType()Lnet/minecraft/world/dimension/DimensionType;"))
private DimensionType arclight$nightTimeType(Dimension dimension) {
return ((DimensionTypeBridge) dimension.getType()).bridge$getType();
}
public CraftServer getServer() {
return (CraftServer) Bukkit.getServer();
}

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.world.biome;
package io.izzel.arclight.common.mixin.core.world.biome;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome;

View File

@ -2,13 +2,20 @@ package io.izzel.arclight.common.mixin.core.world.chunk;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.common.bridge.world.chunk.ChunkBridge;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.fluid.Fluid;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.palette.UpgradeData;
import net.minecraft.world.ITickList;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeContainer;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraft.world.chunk.ChunkSection;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.CraftChunk;
import org.bukkit.event.world.ChunkLoadEvent;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@ -20,6 +27,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import javax.annotation.Nullable;
import java.util.function.Consumer;
@Mixin(Chunk.class)
public abstract class ChunkMixin implements ChunkBridge {
@ -38,6 +46,11 @@ public abstract class ChunkMixin implements ChunkBridge {
public boolean needsDecoration;
private transient boolean arclight$doPlace;
@Inject(method = "<init>(Lnet/minecraft/world/World;Lnet/minecraft/util/math/ChunkPos;Lnet/minecraft/world/biome/BiomeContainer;Lnet/minecraft/util/palette/UpgradeData;Lnet/minecraft/world/ITickList;Lnet/minecraft/world/ITickList;J[Lnet/minecraft/world/chunk/ChunkSection;Ljava/util/function/Consumer;)V", at = @At("RETURN"))
private void arclight$init(World worldIn, ChunkPos chunkPosIn, BiomeContainer biomeContainerIn, UpgradeData upgradeDataIn, ITickList<Block> tickBlocksIn, ITickList<Fluid> tickFluidsIn, long inhabitedTimeIn, ChunkSection[] sectionsIn, Consumer<Chunk> postLoadConsumerIn, CallbackInfo ci) {
bridge$setBukkitChunk(new CraftChunk((Chunk) (Object) this));
}
public org.bukkit.Chunk getBukkitChunk() {
return bukkitChunk;
}

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.world.dimension;
package io.izzel.arclight.common.mixin.core.world.dimension;
import io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge;
import net.minecraft.world.World;
@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.function.BiFunction;
@Mixin(DimensionType.class)
public class DimensionTypeMixin_1_15 implements DimensionTypeBridge {
public class DimensionTypeMixin implements DimensionTypeBridge {
protected void arclight$constructor(int idIn, String suffixIn, String directoryIn, BiFunction<World, DimensionType, ? extends Dimension> p_i49935_4_, boolean p_i49935_5_, IBiomeMagnifier p_i225789_6_) {
throw new RuntimeException();

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.world.gen.feature.structure;
package io.izzel.arclight.common.mixin.core.world.gen.feature.structure;
import io.izzel.arclight.common.bridge.world.IWorldWriterBridge;
import net.minecraft.util.math.ChunkPos;
@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Random;
@Mixin(SwampHutPiece.class)
public class SwampHutPieceMixin_1_15 {
public class SwampHutPieceMixin {
@Inject(method = "create", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/IWorld;addEntity(Lnet/minecraft/entity/Entity;)Z"))
public void arclight$spawnReason(IWorld worldIn, ChunkGenerator<?> chunkGeneratorIn, Random randomIn, MutableBoundingBox mutableBoundingBoxIn, ChunkPos chunkPosIn, CallbackInfoReturnable<Boolean> cir) {

View File

@ -24,6 +24,7 @@ import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.server.ServerWorldLightManager;
import net.minecraft.world.server.TicketManager;
import net.minecraft.world.server.TicketType;
import net.minecraft.world.spawner.WorldEntitySpawner;
import net.minecraft.world.storage.WorldInfo;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@ -174,7 +175,7 @@ public abstract class ServerChunkProviderMixin implements ServerChunkProviderBri
if (entityclassification != EntityClassification.MISC && (!entityclassification.getPeacefulCreature() || this.spawnPassives) && (entityclassification.getPeacefulCreature() || this.spawnHostiles) && (!entityclassification.getAnimal() || flag2)) {
int i1 = limit * l / field_217238_b;
if (object2intmap.getInt(entityclassification) <= i1) {
this.bridge$worldNaturalSpawn(entityclassification, this.world, chunk, blockpos);
WorldEntitySpawner.spawnEntitiesInChunk(entityclassification, this.world, chunk, blockpos);
}
}
}

View File

@ -1,6 +1,5 @@
package io.izzel.arclight.common.mixin.v1_15.world.server;
package io.izzel.arclight.common.mixin.core.world.server;
import io.izzel.arclight.common.mixin.core.world.server.ServerWorldMixin;
import net.minecraft.profiler.IProfiler;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.border.IBorderListener;
@ -18,7 +17,7 @@ import org.spongepowered.asm.mixin.Shadow;
import java.util.concurrent.Executor;
@Mixin(ServerMultiWorld.class)
public abstract class ServerMultiWorldMixin_1_15 extends ServerWorldMixin {
public abstract class ServerMultiWorldMixin extends ServerWorldMixin {
// @formatter:off
@Shadow(remap = false) @Final @Mutable private ServerWorld delegate;

View File

@ -18,6 +18,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.effect.LightningBoltEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
@ -52,6 +53,7 @@ import org.bukkit.entity.LightningStrike;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.server.MapInitializeEvent;
import org.bukkit.event.weather.LightningStrikeEvent;
import org.bukkit.event.world.TimeSkipEvent;
import org.bukkit.event.world.WorldSaveEvent;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
@ -90,6 +92,8 @@ public abstract class ServerWorldMixin extends WorldMixin implements ServerWorld
@Shadow @Final public Int2ObjectMap<Entity> entitiesById;
@Shadow public abstract ServerChunkProvider getChunkProvider();
@Shadow @Final @Mutable @Nullable private WanderingTraderSpawner wanderingTraderSpawner;
@Shadow private boolean allPlayersSleeping;
@Shadow protected abstract void wakeUpAllPlayers();
// @formatter:on
public void arclight$constructor(MinecraftServer serverIn, Executor executor, SaveHandler saveHandler, WorldInfo worldInfo, DimensionType dimType, IProfiler profiler, IChunkStatusListener listener) {
@ -104,7 +108,7 @@ public abstract class ServerWorldMixin extends WorldMixin implements ServerWorld
}
public <T extends IParticleData> int sendParticles(final ServerPlayerEntity sender, final T t0, final double d0, final double d1, final double d2, final int i, final double d3, final double d4, final double d5, final double d6, final boolean force) {
SSpawnParticlePacket packet = new SSpawnParticlePacket((T) t0, force, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
SSpawnParticlePacket packet = new SSpawnParticlePacket(t0, force, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
int j = 0;
for (ServerPlayerEntity entity : this.players) {
if (sender == null || ((ServerPlayerEntityBridge) entity).bridge$getBukkitEntity().canSee(((ServerPlayerEntityBridge) sender).bridge$getBukkitEntity())) {
@ -368,4 +372,25 @@ public abstract class ServerWorldMixin extends WorldMixin implements ServerWorld
}
return map;
}
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setDayTime(J)V"))
private void arclight$timeSkip(ServerWorld world, long time) {
TimeSkipEvent event = new TimeSkipEvent(this.bridge$getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (time - time % 24000L) - this.getDayTime());
Bukkit.getPluginManager().callEvent(event);
arclight$timeSkipCancelled = event.isCancelled();
if (!event.isCancelled()) {
world.setDayTime(this.getDayTime() + event.getSkipAmount());
this.allPlayersSleeping = this.players.stream().allMatch(LivingEntity::isSleeping);
}
}
private transient boolean arclight$timeSkipCancelled;
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;wakeUpAllPlayers()V"))
private void arclight$notWakeIfCancelled(ServerWorld world) {
if (!arclight$timeSkipCancelled) {
this.wakeUpAllPlayers();
}
arclight$timeSkipCancelled = false;
}
}

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.world.server;
package io.izzel.arclight.common.mixin.core.world.server;
import io.izzel.arclight.common.bridge.world.server.TicketManagerBridge;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.gen.Invoker;
import java.util.Iterator;
@Mixin(TicketManager.class)
public abstract class TicketManagerMixin_1_15 implements TicketManagerBridge {
public abstract class TicketManagerMixin implements TicketManagerBridge {
// @formatter:off
@Shadow private long currentTime;

View File

@ -5,7 +5,6 @@ import io.izzel.arclight.common.bridge.world.WorldBridge;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntitySpawnPlacementRegistry;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ILivingEntityData;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.SpawnReason;
import net.minecraft.nbt.CompoundNBT;
@ -117,7 +116,7 @@ public abstract class AbstractSpawnerMixin {
return;
}
int k = world.getEntitiesWithinAABB(entity.getClass(), (new AxisAlignedBB((double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ(), (double) (blockpos.getX() + 1), (double) (blockpos.getY() + 1), (double) (blockpos.getZ() + 1))).grow((double) this.spawnRange)).size();
int k = world.getEntitiesWithinAABB(entity.getClass(), (new AxisAlignedBB(blockpos.getX(), blockpos.getY(), blockpos.getZ(), blockpos.getX() + 1, blockpos.getY() + 1, blockpos.getZ() + 1)).grow(this.spawnRange)).size();
if (k >= this.maxNearbyEntities) {
this.resetTimer();
return;
@ -131,7 +130,7 @@ public abstract class AbstractSpawnerMixin {
}
if (this.spawnData.getNbt().size() == 1 && this.spawnData.getNbt().contains("id", 8)) {
((MobEntity) entity).onInitialSpawn(world, world.getDifficultyForLocation(new BlockPos(entity)), SpawnReason.SPAWNER, (ILivingEntityData) null, (CompoundNBT) null);
((MobEntity) entity).onInitialSpawn(world, world.getDifficultyForLocation(new BlockPos(entity)), SpawnReason.SPAWNER, null, null);
}
if (((WorldBridge) mobentity.world).bridge$spigotConfig().nerfSpawnerMobs) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.world.spawner;
package io.izzel.arclight.common.mixin.core.world.spawner;
import io.izzel.arclight.common.bridge.world.IWorldWriterBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
@ -18,7 +18,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Random;
@Mixin(WorldEntitySpawner.class)
public class WorldEntitySpawnerMixin_1_15 {
public class WorldEntitySpawnerMixin {
@Inject(method = "spawnEntitiesInChunk", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private static void arclight$naturalSpawn(EntityClassification p_222263_0_, ServerWorld worldIn, Chunk p_222263_2_, BlockPos p_222263_3_, CallbackInfo ci) {

View File

@ -54,7 +54,7 @@ public abstract class MapDataMixin implements MapDataBridge {
if (type == null) {
/* All Maps which do not have their valid world loaded are set to a dimension which hopefully won't be reached.
This is to prevent them being corrupted with the wrong map data. */
type = this.bridge$dimension(ArclightConstants.ARCLIGHT_DIMENSION, "", "", OverworldDimension::new, false);
type = new DimensionType(ArclightConstants.ARCLIGHT_DIMENSION, "", "", OverworldDimension::new, false, null, null, null);
((DimensionTypeBridge) type).bridge$setType(DimensionType.OVERWORLD);
}

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.world.storage.loot;
package io.izzel.arclight.common.mixin.core.world.storage.loot;
import com.google.common.collect.ImmutableMap;
import com.google.gson.JsonObject;

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.v1_15.world.storage.loot;
package io.izzel.arclight.common.mixin.core.world.storage.loot;
import io.izzel.arclight.common.bridge.world.storage.loot.LootTableBridge;
import net.minecraft.inventory.IInventory;

View File

@ -1,61 +0,0 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.AbstractButtonBlock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.state.BooleanProperty;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.spongepowered.asm.mixin.Final;
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;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Random;
@Mixin(AbstractButtonBlock.class)
public class AbstractButtonBlockMixin_1_15 {
// @formatter:off
@Shadow @Final public static BooleanProperty POWERED;
// @formatter:on
@Inject(method = "onBlockActivated", cancellable = true, at = @At(value = "HEAD"))
public void arclight$blockRedstone1(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit, CallbackInfoReturnable<Boolean> cir) {
if (!state.get(POWERED)) {
boolean powered = state.get(POWERED);
Block block = CraftBlock.at(worldIn, pos);
int old = (powered) ? 15 : 0;
int current = (!powered) ? 15 : 0;
BlockRedstoneEvent event = new BlockRedstoneEvent(block, old, current);
Bukkit.getPluginManager().callEvent(event);
if ((event.getNewCurrent() > 0) == (powered)) {
cir.setReturnValue(true);
}
}
}
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private void arclight$blockRedstone2(BlockState state, ServerWorld worldIn, BlockPos pos, Random rand, CallbackInfo ci) {
Block block = CraftBlock.at(worldIn, pos);
BlockRedstoneEvent event = new BlockRedstoneEvent(block, 15, 0);
Bukkit.getPluginManager().callEvent(event);
if (event.getNewCurrent() > 0) {
ci.cancel();
}
}
}

Some files were not shown because too many files have changed in this diff Show More