All the blocks

This commit is contained in:
IzzelAliz 2020-06-01 18:33:33 +08:00
parent 54c8e3f020
commit c652025fed
93 changed files with 2078 additions and 355 deletions

View File

@ -1,5 +1,7 @@
package io.izzel.arclight.common.bridge.world;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import org.bukkit.craftbukkit.v.CraftServer;
import org.bukkit.craftbukkit.v.CraftWorld;
import org.bukkit.generator.ChunkGenerator;
@ -19,4 +21,6 @@ public interface WorldBridge extends IWorldWriterBridge {
void bridge$setPopulating(boolean populating);
ChunkGenerator bridge$getGenerator();
TileEntity bridge$getTileEntity(BlockPos pos, boolean validate);
}

View File

@ -10,7 +10,6 @@ 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;
@ -26,7 +25,6 @@ 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 {
@ -52,31 +50,6 @@ public class AbstractButtonBlockMixin {
}
}
@SuppressWarnings({"UnresolvedMixinReference", "UnnecessaryQualifiedMemberReference"})
@Inject(method = "Lnet/minecraft/block/AbstractButtonBlock;func_196267_b(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Ljava/util/Random;)V", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;func_180501_a(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"), require = 0)
public void arclight$blockRedstone2_1_14(BlockState state, World worldIn, BlockPos pos, Random random, 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();
}
}
@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"), require = 0)
private void arclight$blockRedstone2_1_15(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();
}
}
@Inject(method = "checkPressed", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;get(Lnet/minecraft/state/IProperty;)Ljava/lang/Comparable;"))
public void arclight$entityInteract(BlockState state, World worldIn, BlockPos pos, CallbackInfo ci,

View File

@ -3,6 +3,8 @@ package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.bridge.block.BlockBridge;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.BlockItemUseContext;
@ -17,6 +19,7 @@ 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 net.minecraftforge.common.extensions.IForgeBlock;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@ -61,14 +64,16 @@ public abstract class BlockMixin implements BlockBridge {
* @author IzzelAliz
* @reason
*/
@Overwrite(aliases = {"func_220077_a"})
@Overwrite
public static List<ItemStack> getDrops(BlockState state, ServerWorld worldIn, BlockPos pos, @Nullable TileEntity tileEntityIn, Entity entityIn, ItemStack stack) {
LootContext.Builder lootcontext$builder = (new LootContext.Builder(worldIn)).withRandom(worldIn.rand).withParameter(LootParameters.POSITION, pos).withParameter(LootParameters.TOOL, stack).withNullableParameter(LootParameters.THIS_ENTITY, entityIn).withNullableParameter(LootParameters.BLOCK_ENTITY, tileEntityIn);
return state.getDrops(lootcontext$builder);
}
public int getExpDrop(BlockState blockState, World world, BlockPos blockPos, ItemStack itemStack) {
return 0;
int silkTouch = EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemStack);
int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, itemStack);
return ((IForgeBlock) this).getExpDrop(blockState, world, blockPos, fortune, silkTouch);
}
@Override

View File

@ -5,29 +5,16 @@ 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)
public class CactusBlockMixin {
@SuppressWarnings({"UnresolvedMixinReference", "UnnecessaryQualifiedMemberReference"})
@Redirect(method = "Lnet/minecraft/block/CactusBlock;func_196267_b(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Ljava/util/Random;)V", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/World;func_175656_a(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"), require = 0)
public boolean arclight$blockGrow_1_14(World world, BlockPos pos, BlockState state) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, state);
}
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"), require = 0)
private boolean arclight$blockGrow_1_15(ServerWorld serverWorld, BlockPos pos, BlockState state) {
return CraftEventFactory.handleBlockGrowEvent(serverWorld, pos, state);
}
@Inject(method = "onEntityCollision", at = @At("HEAD"))
private void arclight$cactusDamage1(BlockState state, World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) {
CraftEventFactory.blockDamage = CraftBlock.at(worldIn, pos);

View File

@ -1,116 +0,0 @@
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ChorusFlowerBlock;
import net.minecraft.block.ChorusPlantBlock;
import net.minecraft.state.IntegerProperty;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
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.Random;
@Mixin(ChorusFlowerBlock.class)
public abstract class ChorusFlowerBlockMixin extends BlockMixin {
// @formatter:off
@Shadow @Final public static IntegerProperty AGE;
@Shadow @Final private ChorusPlantBlock field_196405_b;
@Shadow private static boolean areAllNeighborsEmpty(IWorldReader worldIn, BlockPos pos, @Nullable Direction excludingSide) { return false; }
@Shadow protected abstract void placeGrownFlower(World worldIn, BlockPos pos, int age);
@Shadow protected abstract void placeDeadFlower(World worldIn, BlockPos pos);
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public void tick(BlockState state, World worldIn, BlockPos pos, Random random) {
if (!state.isValidPosition(worldIn, pos)) {
worldIn.destroyBlock(pos, true);
} else {
BlockPos blockpos = pos.up();
if (worldIn.isAirBlock(blockpos) && blockpos.getY() < worldIn.getDimension().getHeight()) {
int i = state.get(AGE);
if (i < 5 && ForgeHooks.onCropsGrowPre(worldIn, blockpos, state, true)) {
boolean flag = false;
boolean flag1 = false;
BlockState blockstate = worldIn.getBlockState(pos.down());
Block block = blockstate.getBlock();
if (block == Blocks.END_STONE) {
flag = true;
} else if (block == this.field_196405_b) {
int j = 1;
for (int k = 0; k < 4; ++k) {
Block block1 = worldIn.getBlockState(pos.down(j + 1)).getBlock();
if (block1 != this.field_196405_b) {
if (block1 == Blocks.END_STONE) {
flag1 = true;
}
break;
}
++j;
}
if (j < 2 || j <= random.nextInt(flag1 ? 5 : 4)) {
flag = true;
}
} else if (blockstate.isAir(worldIn, pos.down())) {
flag = true;
}
if (flag && areAllNeighborsEmpty(worldIn, blockpos, (Direction) null) && worldIn.isAirBlock(pos.up(2))) {
if (CraftEventFactory.handleBlockSpreadEvent(worldIn, pos, pos.up(), state.with(ChorusFlowerBlock.AGE, i), 2)) {
worldIn.setBlockState(pos, this.field_196405_b.makeConnections(worldIn, pos), 2);
this.placeGrownFlower(worldIn, blockpos, i);
}
} else if (i < 4) {
int l = random.nextInt(4);
if (flag1) {
++l;
}
boolean flag2 = false;
for (int i1 = 0; i1 < l; ++i1) {
Direction direction = Direction.Plane.HORIZONTAL.random(random);
BlockPos blockpos1 = pos.offset(direction);
if (worldIn.isAirBlock(blockpos1) && worldIn.isAirBlock(blockpos1.down()) && areAllNeighborsEmpty(worldIn, blockpos1, direction.getOpposite())) {
if (CraftEventFactory.handleBlockSpreadEvent(worldIn, pos, blockpos1, state.with(ChorusFlowerBlock.AGE, i + 1), 2)) {
this.placeGrownFlower(worldIn, blockpos1, i + 1);
flag2 = true;
}
}
}
if (flag2) {
worldIn.setBlockState(pos, this.field_196405_b.makeConnections(worldIn, pos), 2);
} else {
if (CraftEventFactory.handleBlockGrowEvent(worldIn, pos, this.getDefaultState().with(ChorusFlowerBlock.AGE, 5), 2)) {
this.placeDeadFlower(worldIn, pos);
}
}
} else {
if (CraftEventFactory.handleBlockGrowEvent(worldIn, pos, this.getDefaultState().with(ChorusFlowerBlock.AGE, 5), 2)) {
this.placeDeadFlower(worldIn, pos);
}
}
ForgeHooks.onCropsGrowPost(worldIn, pos, state);
}
}
}
}
}

View File

@ -2,11 +2,15 @@ package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.mixin.core.inventory.InventoryMixin;
import net.minecraft.block.BlockState;
import net.minecraft.block.ComposterBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import org.bukkit.craftbukkit.v.inventory.CraftBlockInventoryHolder;
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;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@ -14,8 +18,30 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(targets = "net.minecraft.block.ComposterBlock$FullInventory")
public abstract class ComposterBlock_FullInventoryMixin extends InventoryMixin {
// @formatter:off
@Shadow @Final private BlockState state;
@Shadow @Final private IWorld world;
@Shadow @Final private BlockPos pos;
@Shadow private boolean extracted;
// @formatter:on
@Inject(method = "<init>(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/item/ItemStack;)V", at = @At("RETURN"))
public void arclight$setOwner(BlockState blockState, IWorld world, BlockPos blockPos, ItemStack itemStack, CallbackInfo ci) {
this.setOwner(new CraftBlockInventoryHolder(world, blockPos, this));
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public void markDirty() {
if (this.isEmpty()) {
ComposterBlock.clear(this.state, this.world, this.pos);
this.extracted = true;
} else {
this.world.setBlockState(this.pos, this.state, 3);
this.extracted = false;
}
}
}

View File

@ -15,11 +15,6 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(CropsBlock.class)
public class CropsBlockMixin {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$blockGrowTick(World world, BlockPos pos, BlockState newState, int flags) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags);
}
@Redirect(method = "grow(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$blockGrowGrow(World world, BlockPos pos, BlockState newState, int flags) {

View File

@ -9,17 +9,11 @@ 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)
public abstract class FarmlandBlockMixin extends BlockMixin {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$moistureChange(World world, BlockPos pos, BlockState newState, int flags) {
return CraftEventFactory.handleMoistureChangeEvent(world, pos, newState, flags);
}
@Inject(method = "turnToDirt", cancellable = true, at = @At("HEAD"))
private static void arclight$blockFade(BlockState state, World worldIn, BlockPos pos, CallbackInfo ci) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, Blocks.DIRT.getDefaultState()).isCancelled()) {

View File

@ -0,0 +1,39 @@
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FenceGateBlock;
import net.minecraft.state.BooleanProperty;
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.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.Redirect;
@Mixin(FenceGateBlock.class)
public class FenceGateBlockMixin {
// @formatter:off
@Shadow @Final public static BooleanProperty POWERED;
// @formatter:on
@Redirect(method = "neighborChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isBlockPowered(Lnet/minecraft/util/math/BlockPos;)Z"))
private boolean arclight$blockRedstone(World world, BlockPos pos, BlockState state) {
boolean powered = world.isBlockPowered(pos);
boolean oldPowered = state.get(POWERED);
if (oldPowered != powered) {
int newPower = powered ? 15 : 0;
int oldPower = oldPowered ? 15 : 0;
Block bukkitBlock = CraftBlock.at(world, pos);
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, newPower);
Bukkit.getPluginManager().callEvent(eventRedstone);
return eventRedstone.getNewCurrent() > 0;
}
return powered;
}
}

View File

@ -55,25 +55,6 @@ public abstract class FireBlockMixin {
}
}
@Redirect(method = "tick", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$fireSpread(World world, BlockPos mutablePos, BlockState newState, int flags,
BlockState state, World 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/World;removeBlock(Lnet/minecraft/util/math/BlockPos;Z)Z"))
public boolean arclight$extinguish1(World world, BlockPos pos, boolean isMoving) {
if (!CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.AIR.getDefaultState()).isCancelled()) {
world.removeBlock(pos, isMoving);
}
return false;
}
@Redirect(method = "onBlockAdded", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;removeBlock(Lnet/minecraft/util/math/BlockPos;Z)Z"))
public boolean arclight$extinguish2(World world, BlockPos pos, boolean isMoving) {
if (!CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.AIR.getDefaultState()).isCancelled()) {

View File

@ -0,0 +1,19 @@
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.JukeboxBlock;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
@Mixin(JukeboxBlock.class)
public class JukeBoxBlockMixin {
@ModifyArg(method = "insertRecord", index = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/tileentity/JukeboxTileEntity;setRecord(Lnet/minecraft/item/ItemStack;)V"))
private ItemStack arclight$oneItem(ItemStack stack) {
if (!stack.isEmpty()) {
stack.setCount(1);
}
return stack;
}
}

View File

@ -0,0 +1,31 @@
package io.izzel.arclight.common.mixin.core.block;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import net.minecraft.block.BlockState;
import net.minecraft.block.LecternBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.LecternTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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.LocalCapture;
@Mixin(LecternBlock.class)
public class LecternBlockMixin {
@Redirect(method = "dropBook", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getTileEntity(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/tileentity/TileEntity;"))
private TileEntity arclight$noValidate(World world, BlockPos pos) {
return ((WorldBridge) world).bridge$getTileEntity(pos, false);
}
@Inject(method = "dropBook", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Direction;getXOffset()I"))
private void arclight$returnIfEmpty(BlockState state, World worldIn, BlockPos pos, CallbackInfo ci, TileEntity tileEntity, LecternTileEntity lecternTileEntity, Direction direction, ItemStack itemStack) {
if (itemStack.isEmpty()) ci.cancel();
}
}

View File

@ -2,27 +2,19 @@ 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;
@ -30,11 +22,6 @@ 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

@ -22,22 +22,22 @@ public abstract class NoteBlockMixin {
@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.triggerNote(worldIn, pos, blockState);
this.play(worldIn, pos, blockState);
}
@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.triggerNote(worldIn, pos, blockState);
this.play(worldIn, pos, blockState);
}
@Redirect(method = "onBlockClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/NoteBlock;triggerNote(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)V"))
public void arclight$callNote3(NoteBlock noteBlock, World worldIn, BlockPos pos, BlockState blockState) {
this.triggerNote(worldIn, pos, blockState);
this.play(worldIn, pos, blockState);
}
private transient BlockState arclight$state;
private void triggerNote(World worldIn, BlockPos pos, BlockState state) {
private void play(World worldIn, BlockPos pos, BlockState state) {
arclight$state = state;
this.triggerNote(worldIn, pos);
arclight$state = null;

View File

@ -2,17 +2,13 @@ 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.state.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;
@ -20,12 +16,8 @@ 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 {
@ -44,54 +36,4 @@ public class PistonBlockMixin {
}
}
}
@Inject(method = "doMove", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE_ASSIGN", remap = false, target = "Lcom/google/common/collect/Sets;newHashSet(Ljava/lang/Iterable;)Ljava/util/HashSet;"))
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

@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable;
@Mixin(RedstoneWireBlock.class)
public class RedstoneWireBlockMixin {
@ModifyVariable(method = "func_212568_b", name = "l", index = 8, at = @At(value = "JUMP", ordinal = 0, opcode = Opcodes.IF_ICMPEQ))
@ModifyVariable(method = "updatePower", name = "l", index = 8, at = @At(value = "JUMP", ordinal = 0, opcode = Opcodes.IF_ICMPEQ))
public int arclight$blockRedstone(int l, World world, BlockPos pos, BlockState state) {
int i = state.get(RedstoneWireBlock.POWER);
if (i != l) {

View File

@ -1,33 +1,18 @@
package io.izzel.arclight.common.mixin.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SaplingBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.TreeType;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.craftbukkit.v.util.BlockStateListPopulator;
import org.bukkit.event.world.StructureGrowEvent;
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.Redirect;
import io.izzel.arclight.common.mod.util.ArclightBlockPopulator;
import io.izzel.arclight.common.mod.util.ArclightCaptures;
import java.util.List;
import java.util.Random;
// todo Re-implement this
@Mixin(SaplingBlock.class)
public abstract class SaplingBlockMixin {
// @formatter:off
@Shadow public abstract void grow(IWorld worldIn, BlockPos pos, BlockState state, Random rand);
//@Shadow public abstract void grow(IWorld worldIn, BlockPos pos, BlockState state, Random rand);
// @formatter:on
@SuppressWarnings("unchecked")
// @SuppressWarnings("unchecked")
/*
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/SaplingBlock;grow(Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Ljava/util/Random;)V"))
public void arclight$treeGrow(SaplingBlock saplingBlock, IWorld worldIn, BlockPos pos, BlockState state, Random rand) {
BlockStateListPopulator populator = new ArclightBlockPopulator(worldIn.getWorld());
@ -41,5 +26,5 @@ public abstract class SaplingBlockMixin {
populator.updateList();
}
}
}
}*/
}

View File

@ -147,6 +147,15 @@ public abstract class WorldMixin implements WorldBridge {
return this.world;
}
public TileEntity getTileEntity(BlockPos pos, boolean validate) {
return getTileEntity(pos);
}
@Override
public TileEntity bridge$getTileEntity(BlockPos pos, boolean validate) {
return getTileEntity(pos, validate);
}
@Override
public CraftServer bridge$getServer() {
return (CraftServer) Bukkit.getServer();

View File

@ -153,7 +153,7 @@ public abstract class ServerWorldMixin extends WorldMixin implements ServerWorld
@Overwrite
@Nullable
public MapData getMapData(String mapName) {
return this.shadow$getServer().func_71218_a(DimensionType.OVERWORLD).getSavedData().get(() -> {
return this.shadow$getServer().getWorld(DimensionType.OVERWORLD).getSavedData().get(() -> {
MapData newMap = new MapData(mapName);
MapInitializeEvent event = new MapInitializeEvent(((MapDataBridge) newMap).bridge$getMapView());
Bukkit.getServer().getPluginManager().callEvent(event);
@ -273,8 +273,13 @@ public abstract class ServerWorldMixin extends WorldMixin implements ServerWorld
@Override
public TileEntity getTileEntity(BlockPos pos) {
return getTileEntity(pos, true);
}
@Override
public TileEntity getTileEntity(BlockPos pos, boolean validate) {
TileEntity result = super.getTileEntity(pos);
if (Thread.currentThread() != arclight$getMainThread()) {
if (!validate || Thread.currentThread() != arclight$getMainThread()) {
return result;
}
@ -301,7 +306,7 @@ public abstract class ServerWorldMixin extends WorldMixin implements ServerWorld
if (type.hasTileEntity(state)) {
TileEntity replacement = type.createTileEntity(state, (IBlockReader) this);
if (replacement == null) return found;
replacement.setWorld((World) (Object) this);
replacement.world = ((World) (Object) this);
this.setTileEntity(pos, replacement);
return replacement;
} else {

View File

@ -0,0 +1,32 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.AbstractButtonBlock;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
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.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(AbstractButtonBlock.class)
public class AbstractButtonBlockMixin_1_15 {
@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

@ -0,0 +1,19 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CactusBlock;
import net.minecraft.util.math.BlockPos;
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.Redirect;
@Mixin(CactusBlock.class)
public class CactusBlockMixin_1_15 {
@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

@ -0,0 +1,28 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import net.minecraft.block.BlockState;
import net.minecraft.block.CakeBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.FoodStats;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(CakeBlock.class)
public class CakeBlockMixin_1_15 {
@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) {
int old = foodStats.getFoodLevel();
FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(player, old + foodLevelIn);
if (!event.isCancelled()) {
foodStats.addStats(event.getFoodLevel() - old, foodSaturationModifier);
}
((ServerPlayerEntityBridge) player).bridge$getBukkitEntity().sendHealthUpdate();
}
}

View File

@ -0,0 +1,103 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import net.minecraft.block.BlockState;
import net.minecraft.block.CauldronBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.potion.PotionUtils;
import net.minecraft.potion.Potions;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.event.block.CauldronLevelChangeEvent;
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(CauldronBlock.class)
public class CauldronBlockMixin_1_15 {
@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) {
int i = state.get(CauldronBlock.LEVEL);
if (!changeLevel(worldIn, pos, state, i - 1, entityIn, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH)) {
ci.cancel();
}
}
@Inject(method = "onBlockActivated", cancellable = true, at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;abilities:Lnet/minecraft/entity/player/PlayerAbilities;"))
public void arclight$levelChange(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit, CallbackInfoReturnable<ActionResultType> cir) {
ItemStack itemStack = player.getHeldItem(handIn);
Item item = itemStack.getItem();
int i = state.get(CauldronBlock.LEVEL);
int newLevel;
CauldronLevelChangeEvent.ChangeReason reason;
if (item == Items.WATER_BUCKET) {
reason = CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY;
newLevel = 3;
} else if (item == Items.BUCKET) {
reason = CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL;
newLevel = 0;
} else if (item == Items.GLASS_BOTTLE) {
reason = CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL;
newLevel = i - 1;
} else if (item == Items.POTION && PotionUtils.getPotionFromItem(itemStack) == Potions.WATER) {
reason = CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY;
newLevel = i + 1;
} else {
reason = null;
newLevel = 0;
}
if (reason != null && !changeLevel(worldIn, pos, state, newLevel, player, reason)) {
cir.setReturnValue(ActionResultType.SUCCESS);
}
}
@Inject(method = "onBlockActivated", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/item/IDyeableArmorItem;removeColor(Lnet/minecraft/item/ItemStack;)V"))
public void arclight$removeColor(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit, CallbackInfoReturnable<ActionResultType> cir) {
int i = state.get(CauldronBlock.LEVEL);
if (!changeLevel(worldIn, pos, state, i - 1, player, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
cir.setReturnValue(ActionResultType.SUCCESS);
}
}
@Inject(method = "onBlockActivated", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/tileentity/BannerTileEntity;removeBannerData(Lnet/minecraft/item/ItemStack;)V"))
public void arclight$removeBanner(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit, CallbackInfoReturnable<ActionResultType> cir) {
int i = state.get(CauldronBlock.LEVEL);
if (!changeLevel(worldIn, pos, state, i - 1, player, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
cir.setReturnValue(ActionResultType.SUCCESS);
}
}
@Inject(method = "fillWithRain", 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$fillRain(World worldIn, BlockPos pos, CallbackInfo ci) {
BlockState state = worldIn.getBlockState(pos);
BlockState cycle = state.cycle(CauldronBlock.LEVEL);
int newLevel = cycle.get(CauldronBlock.LEVEL);
if (!changeLevel(worldIn, pos, state, newLevel, null, CauldronLevelChangeEvent.ChangeReason.UNKNOWN)) {
ci.cancel();
}
}
private boolean changeLevel(World world, BlockPos pos, BlockState state, int i, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) {
int newLevel = MathHelper.clamp(i, 0, 3);
CauldronLevelChangeEvent event = new CauldronLevelChangeEvent(
CraftBlock.at(world, pos),
(entity == null) ? null : ((EntityBridge) entity).bridge$getBukkitEntity(),
reason, state.get(CauldronBlock.LEVEL), newLevel
);
Bukkit.getPluginManager().callEvent(event);
return !event.isCancelled();
}
}

View File

@ -0,0 +1,24 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import io.izzel.arclight.common.mod.util.ChestBlockDoubleInventoryHacks;
import net.minecraft.inventory.DoubleSidedInventory;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.tileentity.ChestTileEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import java.util.Optional;
@Mixin(targets = "net/minecraft/block/ChestBlock$2")
public class ChestBlock2Mixin_1_15 {
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public Optional<INamedContainerProvider> func_225539_a_(final ChestTileEntity p_225539_1_, final ChestTileEntity p_225539_2_) {
final DoubleSidedInventory iinventory = new DoubleSidedInventory(p_225539_1_, p_225539_2_);
return Optional.ofNullable(ChestBlockDoubleInventoryHacks.create(p_225539_1_, p_225539_2_, iinventory));
}
}

View File

@ -0,0 +1,118 @@
package io.izzel.arclight.common.mixin.v1_15.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;
import net.minecraft.block.ChorusFlowerBlock;
import net.minecraft.block.ChorusPlantBlock;
import net.minecraft.state.IntegerProperty;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.ForgeHooks;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
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.Random;
@Mixin(ChorusFlowerBlock.class)
public abstract class ChorusFlowerBlockMixin_1_15 extends BlockMixin {
// @formatter:off
@Shadow @Final public static IntegerProperty AGE;
@Shadow @Final private ChorusPlantBlock field_196405_b;
@Shadow private static boolean areAllNeighborsEmpty(IWorldReader worldIn, BlockPos pos, @Nullable Direction excludingSide) { return false; }
@Shadow protected abstract void placeGrownFlower(World worldIn, BlockPos pos, int age);
@Shadow protected abstract void placeDeadFlower(World worldIn, BlockPos pos);
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) {
if (!state.isValidPosition(worldIn, pos)) {
worldIn.destroyBlock(pos, true);
} else {
BlockPos blockpos = pos.up();
if (worldIn.isAirBlock(blockpos) && blockpos.getY() < worldIn.getDimension().getHeight()) {
int i = state.get(AGE);
if (i < 5 && ForgeHooks.onCropsGrowPre(worldIn, blockpos, state, true)) {
boolean flag = false;
boolean flag1 = false;
BlockState blockstate = worldIn.getBlockState(pos.down());
Block block = blockstate.getBlock();
if (block == Blocks.END_STONE) {
flag = true;
} else if (block == this.field_196405_b) {
int j = 1;
for (int k = 0; k < 4; ++k) {
Block block1 = worldIn.getBlockState(pos.down(j + 1)).getBlock();
if (block1 != this.field_196405_b) {
if (block1 == Blocks.END_STONE) {
flag1 = true;
}
break;
}
++j;
}
if (j < 2 || j <= random.nextInt(flag1 ? 5 : 4)) {
flag = true;
}
} else if (blockstate.isAir(worldIn, pos.down())) {
flag = true;
}
if (flag && areAllNeighborsEmpty(worldIn, blockpos, (Direction) null) && worldIn.isAirBlock(pos.up(2))) {
if (CraftEventFactory.handleBlockSpreadEvent(worldIn, pos, pos.up(), state.with(ChorusFlowerBlock.AGE, i), 2)) {
worldIn.setBlockState(pos, this.field_196405_b.makeConnections(worldIn, pos), 2);
this.placeGrownFlower(worldIn, blockpos, i);
}
} else if (i < 4) {
int l = random.nextInt(4);
if (flag1) {
++l;
}
boolean flag2 = false;
for (int i1 = 0; i1 < l; ++i1) {
Direction direction = Direction.Plane.HORIZONTAL.random(random);
BlockPos blockpos1 = pos.offset(direction);
if (worldIn.isAirBlock(blockpos1) && worldIn.isAirBlock(blockpos1.down()) && areAllNeighborsEmpty(worldIn, blockpos1, direction.getOpposite())) {
if (CraftEventFactory.handleBlockSpreadEvent(worldIn, pos, blockpos1, state.with(ChorusFlowerBlock.AGE, i + 1), 2)) {
this.placeGrownFlower(worldIn, blockpos1, i + 1);
flag2 = true;
}
}
}
if (flag2) {
worldIn.setBlockState(pos, this.field_196405_b.makeConnections(worldIn, pos), 2);
} else {
if (CraftEventFactory.handleBlockGrowEvent(worldIn, pos, this.getDefaultState().with(ChorusFlowerBlock.AGE, 5), 2)) {
this.placeDeadFlower(worldIn, pos);
}
}
} else {
if (CraftEventFactory.handleBlockGrowEvent(worldIn, pos, this.getDefaultState().with(ChorusFlowerBlock.AGE, 5), 2)) {
this.placeDeadFlower(worldIn, pos);
}
}
ForgeHooks.onCropsGrowPost(worldIn, pos, state);
}
}
}
}
}

View File

@ -0,0 +1,19 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CocoaBlock;
import net.minecraft.util.math.BlockPos;
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.Redirect;
@Mixin(CocoaBlock.class)
public class CocoaBlockMixin_1_15 {
@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) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags);
}
}

View File

@ -0,0 +1,31 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CoralBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
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 java.util.Random;
@Mixin(CoralBlock.class)
public class CoralBlockMixin_1_15 {
// @formatter:off
@Shadow @Final private Block deadBlock;
// @formatter:on
@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"))
public void arclight$blockFade(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, this.deadBlock.getDefaultState()).isCancelled()) {
ci.cancel();
}
}
}

View File

@ -0,0 +1,32 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.AbstractCoralPlantBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CoralFinBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
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 java.util.Random;
@Mixin(CoralFinBlock.class)
public class CoralFinBlockMixin_1_15 {
// @formatter:off
@Shadow @Final private Block deadBlock;
// @formatter:on
@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"))
public void arclight$blockFade(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, this.deadBlock.getDefaultState().with(AbstractCoralPlantBlock.WATERLOGGED, false)).isCancelled()) {
ci.cancel();
}
}
}

View File

@ -0,0 +1,32 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.AbstractCoralPlantBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CoralPlantBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
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 java.util.Random;
@Mixin(CoralPlantBlock.class)
public class CoralPlantBlockMixin_1_15 {
// @formatter:off
@Shadow @Final private Block deadBlock;
// @formatter:on
@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"))
public void arclight$blockFade(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, this.deadBlock.getDefaultState().with(AbstractCoralPlantBlock.WATERLOGGED, false)).isCancelled()) {
ci.cancel();
}
}
}

View File

@ -0,0 +1,35 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.AbstractCoralPlantBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CoralWallFanBlock;
import net.minecraft.block.DeadCoralWallFanBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
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 java.util.Random;
@Mixin(CoralWallFanBlock.class)
public class CoralWallFanBlockMixin_1_15 {
// @formatter:off
@Shadow @Final private Block deadBlock;
// @formatter:on
@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"))
public void arclight$blockFade(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, this.deadBlock.getDefaultState()
.with(AbstractCoralPlantBlock.WATERLOGGED, Boolean.FALSE)
.with(DeadCoralWallFanBlock.FACING, state.get(DeadCoralWallFanBlock.FACING))).isCancelled()) {
ci.cancel();
}
}
}

View File

@ -0,0 +1,19 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CropsBlock;
import net.minecraft.util.math.BlockPos;
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.Redirect;
@Mixin(CropsBlock.class)
public class CropsBlockMixin_1_15 {
@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

@ -0,0 +1,19 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FarmlandBlock;
import net.minecraft.util.math.BlockPos;
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.Redirect;
@Mixin(FarmlandBlock.class)
public class FarmlandBlockMixin_1_15 {
@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

@ -0,0 +1,34 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.FireBlock;
import net.minecraft.util.math.BlockPos;
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.Redirect;
@Mixin(FireBlock.class)
public class FireBlockMixin_1_15 {
@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;
}
}

View File

@ -0,0 +1,19 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.GrassBlock;
import net.minecraft.util.math.BlockPos;
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.Redirect;
@Mixin(GrassBlock.class)
public class GrassBlockMixin_1_15 {
@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) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags);
}
}

View File

@ -0,0 +1,19 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.KelpTopBlock;
import net.minecraft.util.math.BlockPos;
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.Redirect;
@Mixin(KelpTopBlock.class)
public class KelpTopBlockMixin_1_15 {
@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) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, state);
}
}

View File

@ -0,0 +1,28 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.LeavesBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.event.block.LeavesDecayEvent;
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(LeavesBlock.class)
public class LeavesBlockMixin_1_15 {
@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) {
LeavesDecayEvent event = new LeavesDecayEvent(CraftBlock.at(worldIn, pos));
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled() || worldIn.getBlockState(pos).getBlock() != (Object) this) {
ci.cancel();
}
}
}

View File

@ -0,0 +1,38 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.LeverBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
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.BlockRedstoneEvent;
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.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(LeverBlock.class)
public class LeverBlockMixin_1_15 {
@Inject(method = "onBlockActivated", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD
, at = @At(value = "INVOKE", target = "Lnet/minecraft/block/LeverBlock;setPowered(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;"))
public void arclight$blockRedstone(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit, CallbackInfoReturnable<Boolean> cir,
boolean flag) {
Block block = CraftBlock.at(worldIn, pos);
int old = (flag) ? 15 : 0;
int current = (!flag) ? 15 : 0;
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
Bukkit.getPluginManager().callEvent(eventRedstone);
if ((eventRedstone.getNewCurrent() > 0) == flag) {
cir.setReturnValue(true);
}
}
}

View File

@ -0,0 +1,20 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.MushroomBlock;
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.Redirect;
@Mixin(MushroomBlock.class)
public class MushroomBlockMixin_1_15 {
@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, World worldIn, BlockPos fromPos) {
return CraftEventFactory.handleBlockSpreadEvent(world, fromPos, toPos, newState, flags);
}
}

View File

@ -0,0 +1,25 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import io.izzel.arclight.common.bridge.entity.EntityTypeBridge;
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.World;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(NetherPortalBlock.class)
public class NetherPortalBlockMixin_1_15 {
@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);
}
}

View File

@ -0,0 +1,19 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.NetherWartBlock;
import net.minecraft.util.math.BlockPos;
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.Redirect;
@Mixin(NetherWartBlock.class)
public class NetherWartBlockMixin_1_15 {
@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) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags);
}
}

View File

@ -0,0 +1,31 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ObserverBlock;
import net.minecraft.util.math.BlockPos;
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(ObserverBlock.class)
public class ObserverBlockMixin_1_15 {
@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) {
if (CraftEventFactory.callRedstoneChange(worldIn, pos, 15, 0).getNewCurrent() != 0) {
ci.cancel();
}
}
@Inject(method = "tick", cancellable = true, 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 void arclight$redstoneChange2(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) {
if (CraftEventFactory.callRedstoneChange(worldIn, pos, 0, 15).getNewCurrent() != 15) {
ci.cancel();
}
}
}

View File

@ -0,0 +1,76 @@
package io.izzel.arclight.common.mixin.v1_15.block;
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.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
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_1_15 {
@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

@ -0,0 +1,31 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.RedstoneDiodeBlock;
import net.minecraft.util.math.BlockPos;
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(RedstoneDiodeBlock.class)
public class RedstoneDiodeBlockMixin_1_15 {
@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) {
if (CraftEventFactory.callRedstoneChange(worldIn, pos, 15, 0).getNewCurrent() != 0) {
ci.cancel();
}
}
@Inject(method = "tick", cancellable = true, 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 void arclight$turnOn(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) {
if (CraftEventFactory.callRedstoneChange(worldIn, pos, 0, 15).getNewCurrent() != 15) {
ci.cancel();
}
}
}

View File

@ -0,0 +1,24 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.RedstoneLampBlock;
import net.minecraft.util.math.BlockPos;
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_1_15 {
@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();
}
}
}

View File

@ -0,0 +1,85 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import net.minecraft.block.BlockState;
import net.minecraft.block.RedstoneOreBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
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.craftbukkit.v.block.CraftBlock;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.player.PlayerInteractEvent;
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(RedstoneOreBlock.class)
public abstract class RedstoneOreBlockMixin_1_15 {
// @formatter:off
@Shadow private static void activate(BlockState p_196500_0_, World p_196500_1_, BlockPos p_196500_2_) { }
// @formatter:on
private static transient Entity arclight$entity;
@Inject(method = "onBlockClicked", at = @At(value = "HEAD"))
public void arclight$interact1(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, CallbackInfo ci) {
arclight$entity = player;
}
@Inject(method = "onEntityWalk", at = @At(value = "HEAD"))
public void arclight$entityInteract(World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) {
if (entityIn instanceof PlayerEntity) {
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(((PlayerEntity) entityIn), Action.PHYSICAL, pos, null, null, null);
if (event.isCancelled()) {
ci.cancel();
return;
}
} else {
EntityInteractEvent event = new EntityInteractEvent(((EntityBridge) entityIn).bridge$getBukkitEntity(), CraftBlock.at(worldIn, pos));
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
ci.cancel();
return;
}
}
arclight$entity = entityIn;
}
@Inject(method = "onBlockActivated", at = @At(value = "HEAD"))
public void arclight$interact3(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit, CallbackInfoReturnable<Boolean> cir) {
arclight$entity = player;
}
@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$blockFade(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, state.with(RedstoneOreBlock.LIT, false)).isCancelled()) {
ci.cancel();
}
}
private static void interact(BlockState blockState, World world, BlockPos blockPos, Entity entity) {
arclight$entity = entity;
activate(blockState, world, blockPos);
}
@Inject(method = "activate", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private static void arclight$entityChangeBlock(BlockState blockState, World world, BlockPos blockPos, CallbackInfo ci) {
if (CraftEventFactory.callEntityChangeBlockEvent(arclight$entity, blockPos, blockState.with(RedstoneOreBlock.LIT, true)).isCancelled()) {
ci.cancel();
}
arclight$entity = null;
}
}

View File

@ -0,0 +1,32 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ScaffoldingBlock;
import net.minecraft.state.IProperty;
import net.minecraft.util.math.BlockPos;
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.Redirect;
import java.util.Random;
@Mixin(ScaffoldingBlock.class)
public class ScaffoldingBlockMixin_1_15 {
@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) {
Integer integer = state.get(property);
if (integer == 7) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, Blocks.AIR.getDefaultState()).isCancelled()) {
return 6;
} else {
return integer;
}
} else {
return integer;
}
}
}

View File

@ -0,0 +1,25 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.SnowBlock;
import net.minecraft.util.math.BlockPos;
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(SnowBlock.class)
public class SnowBlockMixin_1_15 {
@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) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, Blocks.AIR.getDefaultState()).isCancelled()) {
ci.cancel();
}
}
}

View File

@ -0,0 +1,32 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.SpreadableSnowyDirtBlock;
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;
import java.util.Random;
@Mixin(SpreadableSnowyDirtBlock.class)
public class SpreadableSnowyDirtBlockMixin_1_15 {
@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) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, Blocks.DIRT.getDefaultState()).isCancelled()) {
ci.cancel();
}
}
@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;)Z"))
public boolean arclight$blockSpread(ServerWorld world, BlockPos to, BlockState state, BlockState state1, World worldIn, BlockPos from) {
return CraftEventFactory.handleBlockSpreadEvent(world, from, to, state);
}
}

View File

@ -0,0 +1,43 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.StemBlock;
import net.minecraft.util.math.BlockPos;
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;
import java.util.Random;
@Mixin(StemBlock.class)
public class StemBlockMixin_1_15 {
private transient boolean arclight$success = false;
@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$cropGrow1(ServerWorld world, BlockPos pos, BlockState newState, int flags) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags);
}
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
public void arclight$returnIfFail(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) {
if (!arclight$success) {
ci.cancel();
}
arclight$success = false;
}
@Redirect(method = "tick", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
public boolean arclight$cropGrow2(ServerWorld world, BlockPos pos, BlockState state) {
return arclight$success = CraftEventFactory.handleBlockGrowEvent(world, pos, state);
}
@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$cropGrow3(ServerWorld world, BlockPos pos, BlockState newState, int flags) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags);
}
}

View File

@ -0,0 +1,19 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SugarCaneBlock;
import net.minecraft.util.math.BlockPos;
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.Redirect;
@Mixin(SugarCaneBlock.class)
public class SugarCaneBlockMixin_1_15 {
@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

@ -0,0 +1,34 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SweetBerryBushBlock;
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(SweetBerryBushBlock.class)
public class SweetBerryBushBlockMixin_1_15 {
@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) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags);
}
@Inject(method = "onEntityCollision", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z"))
public void arclight$damagePre(BlockState state, World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) {
CraftEventFactory.blockDamage = CraftBlock.at(worldIn, pos);
}
@Inject(method = "onEntityCollision", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/entity/Entity;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z"))
public void arclight$damagePost(BlockState state, World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) {
CraftEventFactory.blockDamage = null;
}
}

View File

@ -0,0 +1,49 @@
package io.izzel.arclight.common.mixin.v1_15.block;
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.state.IntegerProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.CreatureSpawnEvent;
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_1_15 {
@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);
}
}
}

View File

@ -0,0 +1,126 @@
package io.izzel.arclight.common.mixin.v1_15.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;
import net.minecraft.state.BooleanProperty;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
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 java.util.Random;
@Mixin(VineBlock.class)
public abstract class VineBlockMixin_1_15 extends BlockMixin {
// @formatter:off
@Shadow protected abstract BlockState func_196545_h(BlockState p_196545_1_, IBlockReader p_196545_2_, BlockPos p_196545_3_);
@Shadow protected abstract boolean func_196543_i(BlockState p_196543_1_);
@Shadow public static BooleanProperty getPropertyFor(Direction side) { return null; }
@Shadow protected abstract boolean func_196539_a(IBlockReader p_196539_1_, BlockPos p_196539_2_);
@Shadow public static boolean canAttachTo(IBlockReader p_196542_0_, BlockPos worldIn, Direction neighborPos) { return false; }
@Shadow @Final public static BooleanProperty UP;
@Shadow protected abstract boolean func_196541_a(IBlockReader p_196541_1_, BlockPos p_196541_2_, Direction p_196541_3_);
@Shadow protected abstract boolean func_196540_x(BlockState p_196540_1_);
@Shadow protected abstract BlockState func_196544_a(BlockState p_196544_1_, BlockState p_196544_2_, Random p_196544_3_);
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@SuppressWarnings("ConstantConditions")
@Overwrite
public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) {
BlockState blockstate = this.func_196545_h(state, worldIn, pos);
if (blockstate != state) {
if (this.func_196543_i(blockstate)) {
worldIn.setBlockState(pos, blockstate, 2);
} else {
Block.spawnDrops(state, worldIn, pos);
worldIn.removeBlock(pos, false);
}
} else if (worldIn.rand.nextInt(4) == 0 && worldIn.isAreaLoaded(pos, 4)) { // Forge: check area to prevent loading unloaded chunks
Direction direction = Direction.random(random);
BlockPos blockpos = pos.up();
if (direction.getAxis().isHorizontal() && !state.get(getPropertyFor(direction))) {
if (this.func_196539_a(worldIn, pos)) {
BlockPos blockpos4 = pos.offset(direction);
BlockState blockstate5 = worldIn.getBlockState(blockpos4);
if (blockstate5.isAir()) {
Direction direction3 = direction.rotateY();
Direction direction4 = direction.rotateYCCW();
boolean flag = state.get(getPropertyFor(direction3));
boolean flag1 = state.get(getPropertyFor(direction4));
BlockPos blockpos2 = blockpos4.offset(direction3);
BlockPos blockpos3 = blockpos4.offset(direction4);
if (flag && canAttachTo(worldIn, blockpos2, direction3)) {
CraftEventFactory.handleBlockSpreadEvent(worldIn, pos, blockpos4, this.getDefaultState().with(getPropertyFor(direction3), true), 2);
} else if (flag1 && canAttachTo(worldIn, blockpos3, direction4)) {
CraftEventFactory.handleBlockSpreadEvent(worldIn, pos, blockpos4, this.getDefaultState().with(getPropertyFor(direction4), true), 2);
} else {
Direction direction1 = direction.getOpposite();
if (flag && worldIn.isAirBlock(blockpos2) && canAttachTo(worldIn, pos.offset(direction3), direction1)) {
CraftEventFactory.handleBlockSpreadEvent(worldIn, pos, blockpos2, this.getDefaultState().with(getPropertyFor(direction1), true), 2);
} else if (flag1 && worldIn.isAirBlock(blockpos3) && canAttachTo(worldIn, pos.offset(direction4), direction1)) {
CraftEventFactory.handleBlockSpreadEvent(worldIn, pos, blockpos3, this.getDefaultState().with(getPropertyFor(direction1), true), 2);
} else if ((double) worldIn.rand.nextFloat() < 0.05D && canAttachTo(worldIn, blockpos4.up(), Direction.UP)) {
CraftEventFactory.handleBlockSpreadEvent(worldIn, pos, blockpos4, this.getDefaultState().with(UP, true), 2);
}
}
} else if (canAttachTo(worldIn, blockpos4, direction)) {
worldIn.setBlockState(pos, state.with(getPropertyFor(direction), true), 2);
}
}
} else {
if (direction == Direction.UP && pos.getY() < 255) {
if (this.func_196541_a(worldIn, pos, direction)) {
worldIn.setBlockState(pos, state.with(UP, true), 2);
return;
}
if (worldIn.isAirBlock(blockpos)) {
if (!this.func_196539_a(worldIn, pos)) {
return;
}
BlockState blockstate4 = state;
for (Direction direction2 : Direction.Plane.HORIZONTAL) {
if (random.nextBoolean() || !canAttachTo(worldIn, blockpos.offset(direction2), Direction.UP)) {
blockstate4 = blockstate4.with(getPropertyFor(direction2), false);
}
}
if (this.func_196540_x(blockstate4)) {
CraftEventFactory.handleBlockSpreadEvent(worldIn, pos, blockpos, blockstate4, 2);
}
return;
}
}
if (pos.getY() > 0) {
BlockPos blockpos1 = pos.down();
BlockState blockstate1 = worldIn.getBlockState(blockpos1);
if (blockstate1.isAir() || blockstate1.getBlock() == (Object) this) {
BlockState blockstate2 = blockstate1.isAir() ? this.getDefaultState() : blockstate1;
BlockState blockstate3 = this.func_196544_a(state, blockstate2, random);
if (blockstate2 != blockstate3 && this.func_196540_x(blockstate3)) {
CraftEventFactory.handleBlockSpreadEvent(worldIn, pos, blockpos1, blockstate3, 2);
}
}
}
}
}
}
}

View File

@ -0,0 +1,22 @@
package io.izzel.arclight.common.mixin.v1_15.block;
import io.izzel.arclight.common.bridge.entity.LivingEntityBridge;
import net.minecraft.block.BlockState;
import net.minecraft.block.WitherRoseBlock;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.bukkit.event.entity.EntityPotionEffectEvent;
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;
@Mixin(WitherRoseBlock.class)
public class WitherRoseBlockMixin {
@Inject(method = "onEntityCollision", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;addPotionEffect(Lnet/minecraft/potion/EffectInstance;)Z"))
private void arclight$cause(BlockState state, World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) {
((LivingEntityBridge) entityIn).bridge$pushEffectCause(EntityPotionEffectEvent.Cause.WITHER_ROSE);
}
}

View File

@ -22,6 +22,8 @@ public net.minecraft.item.crafting.Ingredient <init>(Ljava/util/stream/Stream;)V
public net.minecraft.entity.Entity field_70165_t #posX
public net.minecraft.entity.Entity field_70163_u #posY
public net.minecraft.entity.Entity field_70161_v #posZ
public net.minecraft.block.ComposterBlock func_220294_d(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;)V #clear
public net.minecraft.tileentity.TileEntity field_145850_b #world
# Bukkit
public net.minecraft.entity.player.PlayerEntity func_190531_bD()I
public net.minecraft.entity.item.ItemFrameEntity func_174859_a(Lnet/minecraft/util/Direction;)V

View File

@ -10,6 +10,42 @@
"maxShiftBy": 2
},
"mixins": [
"block.AbstractButtonBlockMixin_1_15",
"block.CactusBlockMixin_1_15",
"block.CakeBlockMixin_1_15",
"block.CauldronBlockMixin_1_15",
"block.ChestBlock2Mixin_1_15",
"block.ChorusFlowerBlockMixin_1_15",
"block.CocoaBlockMixin_1_15",
"block.CoralBlockMixin_1_15",
"block.CoralFinBlockMixin_1_15",
"block.CoralPlantBlockMixin_1_15",
"block.CoralWallFanBlockMixin_1_15",
"block.CropsBlockMixin_1_15",
"block.FarmlandBlockMixin_1_15",
"block.FireBlockMixin_1_15",
"block.GrassBlockMixin_1_15",
"block.KelpTopBlockMixin_1_15",
"block.LeavesBlockMixin_1_15",
"block.LeverBlockMixin_1_15",
"block.MushroomBlockMixin_1_15",
"block.NetherPortalBlockMixin_1_15",
"block.NetherWartBlockMixin_1_15",
"block.ObserverBlockMixin_1_15",
"block.PistonBlockMixin_1_15",
"block.RedstoneDiodeBlockMixin_1_15",
"block.RedstoneLampBlockMixin_1_15",
"block.RedstoneOreBlockMixin_1_15",
"block.ScaffoldingBlockMixin_1_15",
"block.SnowBlockMixin_1_15",
"block.SpreadableSnowyDirtBlockMixin_1_15",
"block.StemBlockMixin_1_15",
"block.SugarCaneBlockMixin_1_15",
"block.SweetBerryBushBlockMixin_1_15",
"block.TurtleEggBlockMixin_1_15",
"block.VineBlockMixin_1_15",
"block.WitherRoseBlockMixin",
"io.izzel.arclight.impl.mixin.v1_14.block.FarmlandBlockMixin_1_14",
"world.biome.BiomeContainerMixin"
]
}

View File

@ -21,13 +21,9 @@
"block.BlockStateMixin",
"block.BushBlockMixin",
"block.CactusBlockMixin",
"block.CakeBlockMixin",
"block.CampfireBlockMixin",
"block.CarvedPumpkinBlockMixin",
"block.CauldronBlockMixin",
"block.ChestBlock2Mixin",
"block.ChorusFlowerBlockMixin",
"block.CocoaBlockMixin",
"block.CommandBlockBlockMixin",
"block.ComparatorBlockMixin",
"block.ComposterBlock_EmptyInventoryMixin",
@ -35,10 +31,6 @@
"block.ComposterBlock_PartialInventoryMixin",
"block.ComposterBlockMixin",
"block.ConcretePowderBlockMixin",
"block.CoralBlockMixin",
"block.CoralFinBlockMixin",
"block.CoralPlantBlockMixin",
"block.CoralWallFanBlockMixin",
"block.CropsBlockMixin",
"block.DaylightDetectorBlockMixin",
"block.DetectorRailBlockMixin",
@ -50,27 +42,21 @@
"block.EndPortalBlockMixin",
"block.FallingBlockMixin",
"block.FarmlandBlockMixin",
"block.FenceGateBlockMixin",
"block.FireBlockMixin",
"block.FlowingFluidBlockMixin",
"block.GrassBlockMixin",
"block.IceBlockMixin",
"block.KelpTopBlockMixin",
"block.LeavesBlockMixin",
"block.LeverBlockMixin",
"block.JukeBoxBlockMixin",
"block.LecternBlockMixin",
"block.LilyPadBlockMixin",
"block.MagmaBlockMixin",
"block.MushroomBlockMixin",
"block.NetherPortalBlock_SizeMixin",
"block.NetherPortalBlockMixin",
"block.NetherWartBlockMixin",
"block.NoteBlockMixin",
"block.ObserverBlockMixin",
"block.PistonBlockMixin",
"block.PoweredRailBlockMixin",
"block.PressurePlateBlockMixin",
"block.RedstoneDiodeBlockMixin",
"block.RedstoneLampBlockMixin",
"block.RedstoneOreBlockMixin",
"block.RedstoneTorchBlockMixin",
"block.RedstoneWireBlockMixin",
"block.SaplingBlockMixin",
@ -78,9 +64,7 @@
"block.SilverfishBlockMixin",
"block.SnowBlockMixin",
"block.SpongeBlockMixin",
"block.SpreadableSnowyDirtBlockMixin",
"block.StemBlockMixin",
"block.SugarCaneBlockMixin",
"block.SweetBerryBushBlockMixin",
"block.TNTBlockMixin",
"block.TrapDoorBlockMixin",

View File

@ -68,7 +68,9 @@ def embedLibs = ['org.spongepowered:mixin:0.8', 'org.ow2.asm:asm-util:6.2',
dependencies {
minecraft "net.minecraftforge:forge:$minecraftVersion-$forgeVersion"
compile group: 'org.jetbrains', name: 'annotations', version: '19.0.0'
compile project(':arclight-common')
compile(project(':arclight-common')) {
exclude module: 'forge'
}
embed project(':forge-installer')
for (def lib : embedLibs) {
arclight lib
@ -113,7 +115,7 @@ remapSpigotJar {
}
mixin {
//add sourceSets.main, 'mixins.arclight.refmap.json'
add sourceSets.main, 'mixins.arclight.impl.refmap.json'
}
compileJava {

View File

@ -0,0 +1,32 @@
package io.izzel.arclight.impl.mixin.v1_14.block;
import net.minecraft.block.AbstractButtonBlock;
import net.minecraft.block.BlockState;
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.BlockRedstoneEvent;
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(AbstractButtonBlock.class)
public class AbstractButtonBlockMixin_1_14 {
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private void arclight$blockRedstone2(BlockState state, World worldIn, BlockPos pos, Random random, 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

@ -0,0 +1,19 @@
package io.izzel.arclight.impl.mixin.v1_14.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CactusBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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.Redirect;
@Mixin(CactusBlock.class)
public class CactusBlockMixin_1_14 {
@Redirect(method = "tick", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
public boolean arclight$blockGrow_1_14(World world, BlockPos pos, BlockState state) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, state);
}
}

View File

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

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.block;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import net.minecraft.block.BlockState;
@ -25,7 +25,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(CauldronBlock.class)
public class CauldronBlockMixin {
public class CauldronBlockMixin_1_14 {
@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

@ -0,0 +1,22 @@
package io.izzel.arclight.impl.mixin.v1_14.block;
import io.izzel.arclight.common.mod.util.ChestBlockDoubleInventoryHacks;
import net.minecraft.inventory.DoubleSidedInventory;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.tileentity.ChestTileEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@Mixin(targets = "net/minecraft/block/ChestBlock$2")
public class ChestBlock2Mixin_1_14 {
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public INamedContainerProvider forDouble(ChestTileEntity p_212855_1_, ChestTileEntity p_212855_2_) {
final DoubleSidedInventory iinventory = new DoubleSidedInventory(p_212855_1_, p_212855_2_);
return ChestBlockDoubleInventoryHacks.create(p_212855_1_, p_212855_2_, iinventory);
}
}

View File

@ -0,0 +1,120 @@
package io.izzel.arclight.impl.mixin.v1_14.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ChorusFlowerBlock;
import net.minecraft.block.ChorusPlantBlock;
import net.minecraft.state.IntegerProperty;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
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.Random;
@Mixin(ChorusFlowerBlock.class)
public abstract class ChorusFlowerBlockMixin_1_14 extends Block {
// @formatter:off
@Shadow @Final public static IntegerProperty AGE;
@Shadow @Final private ChorusPlantBlock field_196405_b;
@Shadow private static boolean areAllNeighborsEmpty(IWorldReader worldIn, BlockPos pos, @Nullable Direction excludingSide) { return false; }
@Shadow protected abstract void placeGrownFlower(World worldIn, BlockPos pos, int age);
@Shadow protected abstract void placeDeadFlower(World worldIn, BlockPos pos);
// @formatter:on
public ChorusFlowerBlockMixin_1_14(Properties properties) {
super(properties);
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public void tick(BlockState state, World worldIn, BlockPos pos, Random random) {
if (!state.isValidPosition(worldIn, pos)) {
worldIn.destroyBlock(pos, true);
} else {
BlockPos blockpos = pos.up();
if (worldIn.isAirBlock(blockpos) && blockpos.getY() < worldIn.getDimension().getHeight()) {
int i = state.get(AGE);
if (i < 5 && ForgeHooks.onCropsGrowPre(worldIn, blockpos, state, true)) {
boolean flag = false;
boolean flag1 = false;
BlockState blockstate = worldIn.getBlockState(pos.down());
Block block = blockstate.getBlock();
if (block == Blocks.END_STONE) {
flag = true;
} else if (block == this.field_196405_b) {
int j = 1;
for (int k = 0; k < 4; ++k) {
Block block1 = worldIn.getBlockState(pos.down(j + 1)).getBlock();
if (block1 != this.field_196405_b) {
if (block1 == Blocks.END_STONE) {
flag1 = true;
}
break;
}
++j;
}
if (j < 2 || j <= random.nextInt(flag1 ? 5 : 4)) {
flag = true;
}
} else if (blockstate.isAir(worldIn, pos.down())) {
flag = true;
}
if (flag && areAllNeighborsEmpty(worldIn, blockpos, (Direction) null) && worldIn.isAirBlock(pos.up(2))) {
if (CraftEventFactory.handleBlockSpreadEvent(worldIn, pos, pos.up(), state.with(ChorusFlowerBlock.AGE, i), 2)) {
worldIn.setBlockState(pos, this.field_196405_b.makeConnections(worldIn, pos), 2);
this.placeGrownFlower(worldIn, blockpos, i);
}
} else if (i < 4) {
int l = random.nextInt(4);
if (flag1) {
++l;
}
boolean flag2 = false;
for (int i1 = 0; i1 < l; ++i1) {
Direction direction = Direction.Plane.HORIZONTAL.random(random);
BlockPos blockpos1 = pos.offset(direction);
if (worldIn.isAirBlock(blockpos1) && worldIn.isAirBlock(blockpos1.down()) && areAllNeighborsEmpty(worldIn, blockpos1, direction.getOpposite())) {
if (CraftEventFactory.handleBlockSpreadEvent(worldIn, pos, blockpos1, state.with(ChorusFlowerBlock.AGE, i + 1), 2)) {
this.placeGrownFlower(worldIn, blockpos1, i + 1);
flag2 = true;
}
}
}
if (flag2) {
worldIn.setBlockState(pos, this.field_196405_b.makeConnections(worldIn, pos), 2);
} else {
if (CraftEventFactory.handleBlockGrowEvent(worldIn, pos, this.getDefaultState().with(ChorusFlowerBlock.AGE, 5), 2)) {
this.placeDeadFlower(worldIn, pos);
}
}
} else {
if (CraftEventFactory.handleBlockGrowEvent(worldIn, pos, this.getDefaultState().with(ChorusFlowerBlock.AGE, 5), 2)) {
this.placeDeadFlower(worldIn, pos);
}
}
ForgeHooks.onCropsGrowPost(worldIn, pos, state);
}
}
}
}
}

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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 {
public class CocoaBlockMixin_1_14 {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$blockGrow(World world, BlockPos pos, BlockState newState, int flags) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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 {
public class CoralBlockMixin_1_14 {
// @formatter:off
@Shadow @Final private Block deadBlock;

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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 {
public class CoralFinBlockMixin_1_14 {
// @formatter:off
@Shadow @Final private Block deadBlock;

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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 {
public class CoralPlantBlockMixin_1_14 {
// @formatter:off
@Shadow @Final private Block deadBlock;

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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 {
public class CoralWallFanBlockMixin_1_14 {
// @formatter:off
@Shadow @Final private Block deadBlock;

View File

@ -0,0 +1,19 @@
package io.izzel.arclight.impl.mixin.v1_14.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CropsBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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.Redirect;
@Mixin(CropsBlock.class)
public class CropsBlockMixin_1_14 {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$blockGrowTick(World world, BlockPos pos, BlockState newState, int flags) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags);
}
}

View File

@ -0,0 +1,19 @@
package io.izzel.arclight.impl.mixin.v1_14.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FarmlandBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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.Redirect;
@Mixin(FarmlandBlock.class)
public class FarmlandBlockMixin_1_14 {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$moistureChange(World world, BlockPos pos, BlockState newState, int flags) {
return CraftEventFactory.handleMoistureChangeEvent(world, pos, newState, flags);
}
}

View File

@ -0,0 +1,34 @@
package io.izzel.arclight.impl.mixin.v1_14.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.FireBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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.Redirect;
@Mixin(FireBlock.class)
public class FireBlockMixin_1_14 {
@Redirect(method = "tick", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$fireSpread(World world, BlockPos mutablePos, BlockState newState, int flags,
BlockState state, World 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/World;removeBlock(Lnet/minecraft/util/math/BlockPos;Z)Z"))
public boolean arclight$extinguish1(World world, BlockPos pos, boolean isMoving) {
if (!CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.AIR.getDefaultState()).isCancelled()) {
world.removeBlock(pos, isMoving);
}
return false;
}
}

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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 {
public class GrassBlockMixin_1_14 {
@Redirect(method = "grow", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$blockGrow(World world, BlockPos pos, BlockState newState, int flags) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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 {
public class KelpTopBlockMixin_1_14 {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
public boolean arclight$blockGrow(World world, BlockPos pos, BlockState state) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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 {
public class LeavesBlockMixin_1_14 {
@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, World worldIn, BlockPos pos, Random random, CallbackInfo ci) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.LeverBlock;
@ -18,7 +18,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(LeverBlock.class)
public class LeverBlockMixin {
public class LeverBlockMixin_1_14 {
@Inject(method = "onBlockActivated", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD
, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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 {
public class MushroomBlockMixin_1_14 {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$blockSpread(World world, BlockPos toPos, BlockState newState, int flags, BlockState state, World worldIn, BlockPos fromPos) {

View File

@ -0,0 +1,25 @@
package io.izzel.arclight.impl.mixin.v1_14.block;
import io.izzel.arclight.common.bridge.entity.EntityTypeBridge;
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.World;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(NetherPortalBlock.class)
public class NetherPortalBlockMixin_1_14 {
@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);
}
}

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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 {
public class NetherWartBlockMixin_1_14 {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public boolean arclight$cropGrow(World world, BlockPos pos, BlockState newState, int flags) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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 {
public class ObserverBlockMixin_1_14 {
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public void arclight$redstoneChange1(BlockState state, World worldIn, BlockPos pos, Random random, CallbackInfo ci) {

View File

@ -0,0 +1,76 @@
package io.izzel.arclight.impl.mixin.v1_14.block;
import net.minecraft.block.Blocks;
import net.minecraft.block.PistonBlock;
import net.minecraft.block.state.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.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
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_1_14 {
@Inject(method = "doMove", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE_ASSIGN", remap = false, target = "Lcom/google/common/collect/Sets;newHashSet(Ljava/lang/Iterable;)Ljava/util/HashSet;"))
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.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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 {
public class RedstoneDiodeBlockMixin_1_14 {
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public void arclight$turnOff(BlockState state, World worldIn, BlockPos pos, Random random, CallbackInfo ci) {

View File

@ -0,0 +1,24 @@
package io.izzel.arclight.impl.mixin.v1_14.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.RedstoneLampBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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_1_14 {
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private void arclight$redstoneChange(BlockState state, World worldIn, BlockPos pos, Random rand, CallbackInfo ci) {
if (CraftEventFactory.callRedstoneChange(worldIn, pos, 15, 0).getNewCurrent() != 0) {
ci.cancel();
}
}
}

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.block;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import net.minecraft.block.BlockState;
@ -25,7 +25,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Random;
@Mixin(RedstoneOreBlock.class)
public abstract class RedstoneOreBlockMixin {
public abstract class RedstoneOreBlockMixin_1_14 {
// @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.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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 {
public class ScaffoldingBlockMixin_1_14 {
@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, World worldIn, BlockPos pos, Random random) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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 {
public class SnowBlockMixin_1_14 {
@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, World worldIn, BlockPos pos, Random random, CallbackInfo ci) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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 {
public class SpreadableSnowyDirtBlockMixin_1_14 {
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
public void arclight$blockFade(BlockState state, World worldIn, BlockPos pos, Random random, CallbackInfo ci) {

View File

@ -1,4 +1,4 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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 {
public class StemBlockMixin_1_14 {
private transient boolean arclight$success = false;

View File

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

View File

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

View File

@ -0,0 +1,51 @@
package io.izzel.arclight.impl.mixin.v1_14.block;
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.state.IntegerProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.CreatureSpawnEvent;
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_1_14 {
@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/World;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, World 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/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private boolean arclight$handledHatch(World world, BlockPos pos, BlockState newState, int flags) {
return true;
}
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/World;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, World worldIn, BlockPos pos, Random random, CallbackInfo ci) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, Blocks.AIR.getDefaultState()).isCancelled()) {
ci.cancel();
} else {
if (!worldIn.isRemote) {
((WorldBridge) worldIn).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.EGG);
}
}
}
}

View File

@ -1,5 +1,6 @@
package io.izzel.arclight.common.mixin.core.block;
package io.izzel.arclight.impl.mixin.v1_14.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;
@ -17,7 +18,7 @@ import org.spongepowered.asm.mixin.Shadow;
import java.util.Random;
@Mixin(VineBlock.class)
public abstract class VineBlockMixin extends BlockMixin {
public abstract class VineBlockMixin_1_14 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

@ -0,0 +1,49 @@
{
"required": true,
"minVersion": "0.8",
"package": "io.izzel.arclight.impl.mixin.v1_14",
"target": "@env(DEFAULT)",
"refmap": "mixins.arclight.impl.refmap.json",
"setSourceFile": true,
"plugin": "io.izzel.arclight.common.mod.ArclightMixinPlugin",
"injectors": {
"maxShiftBy": 2,
"defaultRequire": 1
},
"mixins": [
"block.AbstractButtonBlockMixin_1_14",
"block.CactusBlockMixin_1_14",
"block.CakeBlockMixin_1_14",
"block.CauldronBlockMixin_1_14",
"block.ChestBlock2Mixin_1_14",
"block.ChorusFlowerBlockMixin_1_14",
"block.CocoaBlockMixin_1_14",
"block.CoralBlockMixin_1_14",
"block.CoralFinBlockMixin_1_14",
"block.CoralPlantBlockMixin_1_14",
"block.CoralWallFanBlockMixin_1_14",
"block.CropsBlockMixin_1_14",
"block.FarmlandBlockMixin_1_14",
"block.FireBlockMixin_1_14",
"block.GrassBlockMixin_1_14",
"block.KelpTopBlockMixin_1_14",
"block.LeavesBlockMixin_1_14",
"block.LeverBlockMixin_1_14",
"block.MushroomBlockMixin_1_14",
"block.NetherPortalBlockMixin_1_14",
"block.NetherWartBlockMixin_1_14",
"block.ObserverBlockMixin_1_14",
"block.PistonBlockMixin_1_14",
"block.RedstoneDiodeBlockMixin_1_14",
"block.RedstoneLampBlockMixin_1_14",
"block.RedstoneOreBlockMixin_1_14",
"block.ScaffoldingBlockMixin_1_14",
"block.SnowBlockMixin_1_14",
"block.SpreadableSnowyDirtBlockMixin_1_14",
"block.StemBlockMixin_1_14",
"block.SugarCaneBlockMixin_1_14",
"block.SweetBerryBushBlockMixin_1_14",
"block.TurtleEggBlockMixin_1_14",
"block.VineBlockMixin_1_14"
]
}