1.16: items and recipes

This commit is contained in:
IzzelAliz 2020-08-22 20:26:14 +08:00
parent 026df6e51f
commit e7bc56bd66
38 changed files with 274 additions and 638 deletions

View File

@ -48,6 +48,7 @@ repositories {
maven { url = 'https://repo.codemc.io/repository/nms/' }
maven { url = 'https://files.minecraftforge.net/maven/' }
maven { url = 'https://www.dogforce-games.com/maven/' }
maven { url = 'https://jitpack.io/' }
}
dependencies {
@ -55,6 +56,7 @@ dependencies {
compile "org.spigotmc:spigot-api:$minecraftVersion-R0.1-SNAPSHOT@jar"
compile 'org.jetbrains:annotations:19.0.0'
compile 'org.spongepowered:mixin:0.8'
compile 'com.github.ArclightTeam:mixin-tools:1.0.0'
compile 'jline:jline:2.12.1'
compile 'net.md-5:SpecialSource:1.8.6'
compile 'org.apache.logging.log4j:log4j-jul:2.11.2'

View File

@ -1,19 +0,0 @@
package io.izzel.arclight.common.mixin.core.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 {
@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

@ -17,8 +17,8 @@ public class FurnaceResultSlotMixin {
@Shadow private int removeCount;
// @formatter:on
@Redirect(method = "onCrafting(Lnet/minecraft/item/ItemStack;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/tileentity/AbstractFurnaceTileEntity;func_213995_d(Lnet/minecraft/entity/player/PlayerEntity;)V"))
@Redirect(method = "onCrafting(Lnet/minecraft/item/ItemStack;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/tileentity/AbstractFurnaceTileEntity;unlockRecipes(Lnet/minecraft/entity/player/PlayerEntity;)V"))
public void arclight$furnaceDropExp(AbstractFurnaceTileEntity furnace, PlayerEntity playerEntity, ItemStack stack) {
((AbstractFurnaceTileEntityBridge) furnace).bridge$dropExp(playerEntity, stack, this.removeCount);
((AbstractFurnaceTileEntityBridge) furnace).bridge$dropExp(playerEntity.world, playerEntity.getPositionVec(), playerEntity, stack, this.removeCount);
}
}

View File

@ -7,30 +7,67 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.IProperty;
import net.minecraft.state.Property;
import net.minecraft.state.StateContainer;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.craftbukkit.v.block.CraftBlockState;
import org.bukkit.craftbukkit.v.block.data.CraftBlockData;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockCanBuildEvent;
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.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(BlockItem.class)
public abstract class BlockItemMixin {
// @formatter:off
@Shadow protected abstract boolean checkPosition();
@Shadow private static <T extends Comparable<T>> BlockState func_219988_a(BlockState p_219988_0_, IProperty<T> p_219988_1_, String p_219988_2_) { return null; }
@Shadow private static <T extends Comparable<T>> BlockState func_219988_a(BlockState p_219988_0_, Property<T> p_219988_1_, String p_219988_2_) { return null; }
// @formatter:on
private transient org.bukkit.block.BlockState arclight$state;
@Inject(method = "tryPlace", locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/item/BlockItem;getStateForPlacement(Lnet/minecraft/item/BlockItemUseContext;)Lnet/minecraft/block/BlockState;"))
private void arclight$prePlaceLilypad(BlockItemUseContext context, CallbackInfoReturnable<ActionResultType> cir, BlockItemUseContext context1) {
this.arclight$state = CraftBlockState.getBlockState(context1.getWorld(), context1.getPos());
}
@Inject(method = "tryPlace", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true,
at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/block/Block;onBlockPlacedBy(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;)V"))
private void arclight$postPlaceLilypad(BlockItemUseContext context, CallbackInfoReturnable<ActionResultType> cir, BlockItemUseContext context1) {
org.bukkit.block.BlockState state = arclight$state;
arclight$state = null;
BlockPos pos = context1.getPos();
if (state != null) {
org.bukkit.event.block.BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent((ServerWorld) context1.getWorld(), context1.getPlayer(), context1.getHand(), state, pos.getX(), pos.getY(), pos.getZ());
if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) {
state.update(true, false);
cir.setReturnValue(ActionResultType.FAIL);
}
}
}
@Inject(method = "tryPlace", at = @At("RETURN"))
private void arclight$cleanup(BlockItemUseContext context, CallbackInfoReturnable<ActionResultType> cir) {
this.arclight$state = null;
}
private static BlockState getBlockState(BlockState blockState, CompoundNBT nbt) {
StateContainer<Block, BlockState> statecontainer = blockState.getBlock().getStateContainer();
for (String s : nbt.keySet()) {
IProperty<?> iproperty = statecontainer.getProperty(s);
Property<?> iproperty = statecontainer.getProperty(s);
if (iproperty != null) {
String s1 = nbt.get(s).getString();
blockState = func_219988_a(blockState, iproperty, s1);

View File

@ -14,11 +14,12 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@ -44,17 +45,17 @@ public class BoatItemMixin extends Item {
* @reason
*/
@Overwrite
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
public @NotNull ActionResult<ItemStack> onItemRightClick(@NotNull World worldIn, PlayerEntity playerIn, @NotNull Hand handIn) {
ItemStack itemstack = playerIn.getHeldItem(handIn);
RayTraceResult raytraceresult = rayTrace(worldIn, playerIn, RayTraceContext.FluidMode.ANY);
if (raytraceresult.getType() == RayTraceResult.Type.MISS) {
BlockRayTraceResult result = rayTrace(worldIn, playerIn, RayTraceContext.FluidMode.ANY);
if (result.getType() == RayTraceResult.Type.MISS) {
return new ActionResult<>(ActionResultType.PASS, itemstack);
} else {
Vec3d vec3d = playerIn.getLook(1.0F);
Vector3d vec3d = playerIn.getLook(1.0F);
double d0 = 5.0D;
List<Entity> list = worldIn.getEntitiesInAABBexcluding(playerIn, playerIn.getBoundingBox().expand(vec3d.scale(5.0D)).grow(1.0D), field_219989_a);
if (!list.isEmpty()) {
Vec3d vec3d1 = playerIn.getEyePosition(1.0F);
Vector3d vec3d1 = playerIn.getEyePosition(1.0F);
for (Entity entity : list) {
AxisAlignedBB axisalignedbb = entity.getBoundingBox().grow(entity.getCollisionBorderSize());
@ -64,22 +65,21 @@ public class BoatItemMixin extends Item {
}
}
if (raytraceresult.getType() == RayTraceResult.Type.BLOCK) {
BlockRayTraceResult blockRayTraceResult = (BlockRayTraceResult) raytraceresult;
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(playerIn, Action.RIGHT_CLICK_BLOCK, blockRayTraceResult.getPos(), blockRayTraceResult.getFace(), itemstack, handIn);
if (result.getType() == RayTraceResult.Type.BLOCK) {
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(playerIn, Action.RIGHT_CLICK_BLOCK, result.getPos(), result.getFace(), itemstack, handIn);
if (event.isCancelled()) {
return new ActionResult<>(ActionResultType.PASS, itemstack);
}
BoatEntity boatentity = new BoatEntity(worldIn, raytraceresult.getHitVec().x, raytraceresult.getHitVec().y, raytraceresult.getHitVec().z);
BoatEntity boatentity = new BoatEntity(worldIn, result.getHitVec().x, result.getHitVec().y, result.getHitVec().z);
boatentity.setBoatType(this.type);
boatentity.rotationYaw = playerIn.rotationYaw;
if (!worldIn.hasNoCollisions(boatentity, boatentity.getBoundingBox().grow(-0.1D))) {
return new ActionResult<>(ActionResultType.FAIL, itemstack);
} else {
if (!worldIn.isRemote) {
if (CraftEventFactory.callEntityPlaceEvent(worldIn, blockRayTraceResult.getPos(), blockRayTraceResult.getFace(), playerIn, boatentity).isCancelled()) {
if (CraftEventFactory.callEntityPlaceEvent(worldIn, result.getPos(), result.getFace(), playerIn, boatentity).isCancelled()) {
return new ActionResult<>(ActionResultType.FAIL, itemstack);
}
if (!worldIn.addEntity(boatentity)) {
@ -92,7 +92,7 @@ public class BoatItemMixin extends Item {
}
playerIn.addStat(Stats.ITEM_USED.get(this));
return new ActionResult<>(ActionResultType.SUCCESS, itemstack);
return ActionResult.func_233538_a_(itemstack, worldIn.isRemote());
}
} else {
return new ActionResult<>(ActionResultType.PASS, itemstack);

View File

@ -33,7 +33,7 @@ public abstract class BowItemMixin extends ShootableItem {
// @formatter:off
@Shadow public abstract int getUseDuration(ItemStack stack);
@Shadow public static float getArrowVelocity(int charge) { return 0; }
@Shadow(remap = false) public abstract AbstractArrowEntity customeArrow(AbstractArrowEntity arrow);
@Shadow(remap = false) public abstract AbstractArrowEntity customArrow(AbstractArrowEntity arrow);
// @formatter:on
/**
@ -62,8 +62,8 @@ public abstract class BowItemMixin extends ShootableItem {
if (!worldIn.isRemote) {
ArrowItem arrowitem = (ArrowItem) (itemstack.getItem() instanceof ArrowItem ? itemstack.getItem() : Items.ARROW);
AbstractArrowEntity abstractarrowentity = arrowitem.createArrow(worldIn, itemstack, playerentity);
abstractarrowentity = customeArrow(abstractarrowentity);
abstractarrowentity.shoot(playerentity, playerentity.rotationPitch, playerentity.rotationYaw, 0.0F, f * 3.0F, 1.0F);
abstractarrowentity = customArrow(abstractarrowentity);
abstractarrowentity.func_234612_a_(playerentity, playerentity.rotationPitch, playerentity.rotationYaw, 0.0F, f * 3.0F, 1.0F);
if (f == 1.0F) {
abstractarrowentity.setIsCritical(true);
}
@ -105,7 +105,7 @@ public abstract class BowItemMixin extends ShootableItem {
}
}
worldIn.playSound(null, playerentity.posX, playerentity.posY, playerentity.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (random.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
worldIn.playSound(null, playerentity.getPosX(), playerentity.getPosY(), playerentity.getPosZ(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (random.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (!flag1 && !playerentity.abilities.isCreativeMode) {
itemstack.shrink(1);
if (itemstack.isEmpty()) {

View File

@ -13,11 +13,11 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.craftbukkit.v.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v.util.DummyGeneratorAccess;
@ -28,7 +28,7 @@ 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.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@ -44,7 +44,7 @@ public abstract class BucketItemMixin {
BlockPos pos = ((BlockRayTraceResult) result).getPos();
BlockState state = worldIn.getBlockState(pos);
Fluid dummyFluid = ((IBucketPickupHandler) state.getBlock()).pickupFluid(DummyGeneratorAccess.INSTANCE, pos, state);
PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(worldIn, playerIn, pos, pos, ((BlockRayTraceResult) result).getFace(), stack, dummyFluid.getFilledBucket());
PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((ServerWorld) worldIn, playerIn, pos, pos, ((BlockRayTraceResult) result).getFace(), stack, dummyFluid.getFilledBucket());
if (event.isCancelled()) {
((ServerPlayerEntity) playerIn).connection.sendPacket(new SChangeBlockPacket(worldIn, pos));
((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity().updateInventory();
@ -72,9 +72,9 @@ public abstract class BucketItemMixin {
private transient org.bukkit.inventory.@Nullable ItemStack arclight$captureItem;
@Redirect(method = "fillBucket", at = @At(value = "NEW", target = "net/minecraft/item/ItemStack"))
private ItemStack arclight$useCapture(IItemProvider fillBucket) {
return arclight$captureItem == null ? new ItemStack(fillBucket) : CraftItemStack.asNMSCopy(arclight$captureItem);
@ModifyArg(method = "onItemRightClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/DrinkHelper;func_242398_a(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/item/ItemStack;)Lnet/minecraft/item/ItemStack;"))
private ItemStack arclight$useEventItem(ItemStack itemStack) {
return arclight$captureItem == null ? itemStack : CraftItemStack.asNMSCopy(arclight$captureItem);
}
public boolean a(PlayerEntity entity, World world, BlockPos pos, @Nullable BlockRayTraceResult result, Direction direction, BlockPos clicked, ItemStack itemstack) {
@ -94,10 +94,10 @@ public abstract class BucketItemMixin {
private transient BlockPos arclight$click;
private transient ItemStack arclight$stack;
@Inject(method = "tryPlaceContainedLiquid", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/dimension/Dimension;doesWaterVaporize()Z"))
@Inject(method = "tryPlaceContainedLiquid", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/DimensionType;func_236040_e_()Z"))
private void arclight$bucketEmpty(PlayerEntity player, World worldIn, BlockPos posIn, BlockRayTraceResult p_180616_4_, CallbackInfoReturnable<Boolean> cir) {
if (player != null) {
PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(worldIn, player, posIn, arclight$click, arclight$direction, arclight$stack);
PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent((ServerWorld) worldIn, player, posIn, arclight$click, arclight$direction, arclight$stack);
if (event.isCancelled()) {
((ServerPlayerEntity) player).connection.sendPacket(new SChangeBlockPacket(worldIn, posIn));
((ServerPlayerEntityBridge) player).bridge$getBukkitEntity().updateInventory();

View File

@ -2,12 +2,14 @@ package io.izzel.arclight.common.mixin.core.item;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.passive.FoxEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ChorusFruitItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
@ -15,6 +17,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@ -30,17 +33,17 @@ public class ChorusFruitItemMixin extends Item {
* @reason
*/
@Overwrite
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) {
public @NotNull ItemStack onItemUseFinish(@NotNull ItemStack stack, @NotNull World worldIn, @NotNull LivingEntity entityLiving) {
ItemStack itemstack = super.onItemUseFinish(stack, worldIn, entityLiving);
if (!worldIn.isRemote) {
double d0 = entityLiving.posX;
double d1 = entityLiving.posY;
double d2 = entityLiving.posZ;
double d0 = entityLiving.getPosX();
double d1 = entityLiving.getPosY();
double d2 = entityLiving.getPosZ();
for (int i = 0; i < 16; ++i) {
double d3 = entityLiving.posX + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
double d4 = MathHelper.clamp(entityLiving.posY + (double) (entityLiving.getRNG().nextInt(16) - 8), 0.0D, worldIn.getActualHeight() - 1);
double d5 = entityLiving.posZ + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
double d3 = entityLiving.getPosX() + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
double d4 = MathHelper.clamp(entityLiving.getPosY() + (double) (entityLiving.getRNG().nextInt(16) - 8), 0.0D, worldIn.func_234938_ad_() - 1);
double d5 = entityLiving.getPosZ() + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
if (entityLiving instanceof ServerPlayerEntity) {
Player player = ((ServerPlayerEntityBridge) entityLiving).bridge$getBukkitEntity();
@ -59,8 +62,9 @@ public class ChorusFruitItemMixin extends Item {
}
if (entityLiving.attemptTeleport(d3, d4, d5, true)) {
worldIn.playSound(null, d0, d1, d2, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
entityLiving.playSound(SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, 1.0F, 1.0F);
SoundEvent soundevent = entityLiving instanceof FoxEntity ? SoundEvents.ENTITY_FOX_TELEPORT : SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT;
worldIn.playSound(null, d0, d1, d2, soundevent, SoundCategory.PLAYERS, 1.0F, 1.0F);
entityLiving.playSound(soundevent, 1.0F, 1.0F);
break;
}
}

View File

@ -2,10 +2,11 @@ package io.izzel.arclight.common.mixin.core.item;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import io.izzel.arclight.mixin.Eject;
import net.minecraft.entity.Entity;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.item.CrossbowItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
@ -15,7 +16,6 @@ import org.bukkit.event.entity.EntityShootBowEvent;
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;
@ -24,8 +24,8 @@ public class CrossbowItemMixin {
@Inject(method = "fireProjectile", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;damageItem(ILnet/minecraft/entity/LivingEntity;Ljava/util/function/Consumer;)V"))
private static void arclight$entityShoot(World worldIn, LivingEntity shooter, Hand handIn, ItemStack crossbow, ItemStack projectile, float soundPitch, boolean isCreativeMode, float velocity, float inaccuracy, float projectileAngle, CallbackInfo ci,
boolean flag, IProjectile proj) {
EntityShootBowEvent event = CraftEventFactory.callEntityShootBowEvent(shooter, crossbow, (Entity) proj, soundPitch);
boolean flag, ProjectileEntity proj) {
EntityShootBowEvent event = CraftEventFactory.callEntityShootBowEvent(shooter, crossbow, proj, soundPitch);
if (event.isCancelled()) {
event.getProjectile().remove();
ci.cancel();
@ -35,26 +35,16 @@ public class CrossbowItemMixin {
private static transient boolean arclight$capturedBoolean;
@Redirect(method = "fireProjectile", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private static boolean arclight$addEntity(World world, Entity entityIn, World worldIn, LivingEntity shooter) {
@Eject(method = "fireProjectile", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private static boolean arclight$addEntity(World world, Entity entityIn, World worldIn, LivingEntity shooter, CallbackInfo ci) {
if (arclight$capturedBoolean) {
if (!world.addEntity(entityIn)) {
if (shooter instanceof ServerPlayerEntity) {
((ServerPlayerEntityBridge) shooter).bridge$getBukkitEntity().updateInventory();
}
arclight$capturedBoolean = true;
} else {
arclight$capturedBoolean = false;
ci.cancel();
}
}
return true;
}
@Inject(method = "fireProjectile", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;playSound(Lnet/minecraft/entity/player/PlayerEntity;DDDLnet/minecraft/util/SoundEvent;Lnet/minecraft/util/SoundCategory;FF)V"))
private static void arclight$returnIfFail(World worldIn, LivingEntity shooter, Hand handIn, ItemStack crossbow, ItemStack projectile, float soundPitch, boolean isCreativeMode, float velocity, float inaccuracy, float projectileAngle, CallbackInfo ci) {
if (arclight$capturedBoolean) {
ci.cancel();
}
arclight$capturedBoolean = false;
}
}

View File

@ -1,6 +1,7 @@
package io.izzel.arclight.common.mixin.core.item;
import io.izzel.arclight.common.bridge.entity.LivingEntityBridge;
import io.izzel.arclight.mixin.Eject;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.passive.SheepEntity;
import net.minecraft.entity.player.PlayerEntity;
@ -15,8 +16,6 @@ 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.CallbackInfoReturnable;
@Mixin(DyeItem.class)
@ -26,23 +25,15 @@ public class DyeItemMixin {
@Shadow @Final private DyeColor dyeColor;
// @formatter:on
@Inject(method = "itemInteractionForEntity", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/SheepEntity;setFleeceColor(Lnet/minecraft/item/DyeColor;)V"))
public void arclight$sheepDyeWool(ItemStack stack, PlayerEntity playerIn, LivingEntity target, Hand hand, CallbackInfoReturnable<Boolean> cir) {
@Eject(method = "itemInteractionForEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/SheepEntity;setFleeceColor(Lnet/minecraft/item/DyeColor;)V"))
private void arclight$sheepDyeWool(SheepEntity sheepEntity, DyeColor color, CallbackInfoReturnable<Boolean> cir, ItemStack stack, PlayerEntity playerIn, LivingEntity target, Hand hand) {
byte bColor = (byte) this.dyeColor.getId();
SheepDyeWoolEvent event = new SheepDyeWoolEvent((Sheep) ((LivingEntityBridge) target).bridge$getBukkitEntity(), org.bukkit.DyeColor.getByWoolData(bColor));
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
cir.setReturnValue(false);
} else {
sheepEntity.setFleeceColor(DyeColor.byId(event.getColor().getWoolData()));
}
arclight$capturedColor = DyeColor.byId(event.getColor().getWoolData());
}
private transient DyeColor arclight$capturedColor;
@Redirect(method = "itemInteractionForEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/SheepEntity;setFleeceColor(Lnet/minecraft/item/DyeColor;)V"))
public void arclight$setColor(SheepEntity sheepEntity, DyeColor color) {
sheepEntity.setFleeceColor(arclight$capturedColor);
arclight$capturedColor = null;
}
}

View File

@ -1,19 +1,23 @@
package io.izzel.arclight.common.mixin.core.item;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import io.izzel.arclight.mixin.Eject;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.projectile.EggEntity;
import net.minecraft.item.EggItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Stats;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.SoundEvents;
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(EggItem.class)
public abstract class EggItemMixin extends Item {
@ -22,26 +26,21 @@ public abstract class EggItemMixin extends Item {
super(properties);
}
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
ItemStack stack = playerIn.getHeldItem(handIn);
if (!worldIn.isRemote) {
EggEntity eggEntity = new EggEntity(worldIn, playerIn);
eggEntity.setItem(stack);
eggEntity.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0f, 1.5f, 1.0f);
if (!worldIn.addEntity(eggEntity)) {
if (playerIn instanceof ServerPlayerEntity) {
((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity().updateInventory();
}
return ActionResult.resultFail(stack);
}
}
worldIn.playSound(null, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5f, 0.4f / (random.nextFloat() * 0.4f + 0.8f));
playerIn.addStat(Stats.ITEM_USED.get(this));
if (!playerIn.abilities.isCreativeMode) {
stack.shrink(1);
}
return ActionResult.resultSuccess(stack);
@Redirect(method = "onItemRightClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;playSound(Lnet/minecraft/entity/player/PlayerEntity;DDDLnet/minecraft/util/SoundEvent;Lnet/minecraft/util/SoundCategory;FF)V"))
private void arclight$muteSound(World world, PlayerEntity player, double x, double y, double z, SoundEvent soundIn, SoundCategory category, float volume, float pitch) {
}
@Eject(method = "onItemRightClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private boolean arclight$updateIfFail(World world, Entity entityIn, CallbackInfoReturnable<ActionResult<ItemStack>> cir, World worldIn, PlayerEntity playerIn, @NotNull Hand handIn) {
if (!worldIn.addEntity(entityIn)) {
if (playerIn instanceof ServerPlayerEntityBridge) {
((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity().updateInventory();
}
cir.setReturnValue(ActionResult.resultFail(playerIn.getHeldItem(handIn)));
return false;
} else {
worldIn.playSound(null, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
return true;
}
}
}

View File

@ -0,0 +1,28 @@
package io.izzel.arclight.common.mixin.core.item;
import io.izzel.arclight.mixin.Eject;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnderEyeItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(EnderEyeItem.class)
public class EnderEyeItemMixin {
@Eject(method = "onItemRightClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private boolean arclight$returnIfFail(World world, Entity entityIn, CallbackInfoReturnable<ActionResult<ItemStack>> cir, World worldIn, PlayerEntity playerIn, Hand handIn) {
if (!world.addEntity(entityIn)) {
cir.setReturnValue(new ActionResult<>(ActionResultType.FAIL, playerIn.getHeldItem(handIn)));
return false;
} else {
return true;
}
}
}

View File

@ -13,6 +13,7 @@ import net.minecraft.util.Hand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@ -28,13 +29,12 @@ public class EnderPearlItemMixin extends Item {
* @reason
*/
@Overwrite
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
public @NotNull ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, @NotNull Hand handIn) {
ItemStack itemstack = playerIn.getHeldItem(handIn);
if (!worldIn.isRemote) {
EnderPearlEntity enderpearlentity = new EnderPearlEntity(worldIn, playerIn);
enderpearlentity.setItem(itemstack);
enderpearlentity.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
enderpearlentity.func_234612_a_(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
if (!worldIn.addEntity(enderpearlentity)) {
if (playerIn instanceof ServerPlayerEntityBridge) {
((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity().updateInventory();
@ -43,14 +43,14 @@ public class EnderPearlItemMixin extends Item {
}
}
worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
worldIn.playSound(null, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
playerIn.getCooldownTracker().setCooldown(this, 20);
playerIn.addStat(Stats.ITEM_USED.get(this));
if (!playerIn.abilities.isCreativeMode) {
itemstack.shrink(1);
}
return new ActionResult<>(ActionResultType.SUCCESS, itemstack);
return ActionResult.func_233538_a_(itemstack, worldIn.isRemote());
}
}

View File

@ -4,8 +4,8 @@ import io.izzel.arclight.common.bridge.world.storage.MapDataBridge;
import net.minecraft.item.FilledMapItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.RegistryKey;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.storage.MapData;
import org.bukkit.Bukkit;
import org.bukkit.event.server.MapInitializeEvent;
@ -21,7 +21,7 @@ public class FilledMapItemMixin {
@Inject(method = "createMapData", locals = LocalCapture.CAPTURE_FAILHARD, at = @At("RETURN"))
private static void arclight$mapInit(ItemStack stack, World worldIn, int x, int z, int scale, boolean trackingPosition,
boolean unlimitedTracking, DimensionType dimensionTypeIn, CallbackInfoReturnable<MapData> cir,
boolean unlimitedTracking, RegistryKey<World> dimensionTypeIn, CallbackInfoReturnable<MapData> cir,
int i, MapData mapData) {
MapInitializeEvent event = new MapInitializeEvent(((MapDataBridge) mapData).bridge$getMapView());
Bukkit.getPluginManager().callEvent(event);

View File

@ -44,7 +44,7 @@ public class FishingRodItemMixin extends Item {
}
playerIn.swingArm(handIn);
worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
worldIn.playSound(null, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ENTITY_FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
} else {
if (!worldIn.isRemote) {
int k = EnchantmentHelper.getFishingSpeedBonus(itemstack);
@ -58,7 +58,7 @@ public class FishingRodItemMixin extends Item {
playerIn.fishingBobber = null;
return new ActionResult<>(ActionResultType.PASS, itemstack);
}
worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
worldIn.playSound(null, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
worldIn.addEntity(new FishingBobberEntity(playerIn, worldIn, j, k));
}
@ -66,6 +66,6 @@ public class FishingRodItemMixin extends Item {
playerIn.addStat(Stats.ITEM_USED.get(this));
}
return new ActionResult<>(ActionResultType.SUCCESS, itemstack);
return ActionResult.func_233538_a_(itemstack, worldIn.isRemote());
}
}

View File

@ -5,7 +5,7 @@ import net.minecraft.item.FlintAndSteelItem;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.block.BlockIgniteEvent;
import org.spongepowered.asm.mixin.Mixin;
@ -16,13 +16,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(FlintAndSteelItem.class)
public class FlintAndSteelItemMixin {
@Inject(method = "onItemUse", cancellable = true, at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/IWorld;playSound(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/SoundEvent;Lnet/minecraft/util/SoundCategory;FF)V"))
@Inject(method = "onItemUse", cancellable = true, 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"))
public void arclight$blockIgnite(ItemUseContext context, CallbackInfoReturnable<ActionResultType> cir) {
PlayerEntity playerentity = context.getPlayer();
IWorld world = context.getWorld();
World world = context.getWorld();
BlockPos blockpos = context.getPos();
BlockPos blockpos1 = blockpos.offset(context.getFace());
if (CraftEventFactory.callBlockIgniteEvent(world.getWorld(), blockpos1, BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, playerentity).isCancelled()) {
if (CraftEventFactory.callBlockIgniteEvent(world, blockpos1, BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, playerentity).isCancelled()) {
context.getItem().damageItem(1, playerentity, (entity) -> {
entity.sendBreakAnimation(context.getHand());
});

View File

@ -1,63 +1,29 @@
package io.izzel.arclight.common.mixin.core.item;
import net.minecraft.block.AbstractRailBlock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.item.ItemStack;
import io.izzel.arclight.mixin.Eject;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemUseContext;
import net.minecraft.item.MinecartItem;
import net.minecraft.state.properties.RailShape;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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 org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(MinecartItem.class)
public class MinecartItemMixin {
// @formatter:off
@Shadow @Final private AbstractMinecartEntity.Type minecartType;
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public ActionResultType onItemUse(ItemUseContext context) {
World world = context.getWorld();
BlockPos blockpos = context.getPos();
BlockState blockstate = world.getBlockState(blockpos);
if (!blockstate.isIn(BlockTags.RAILS)) {
return ActionResultType.FAIL;
@Eject(method = "onItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private boolean arclight$entityPlace(World world, Entity entityIn, CallbackInfoReturnable<ActionResultType> cir, ItemUseContext context) {
if (CraftEventFactory.callEntityPlaceEvent(context, entityIn).isCancelled()) {
cir.setReturnValue(ActionResultType.FAIL);
return false;
} else if (!world.addEntity(entityIn)) {
cir.setReturnValue(ActionResultType.PASS);
return false;
} else {
ItemStack itemstack = context.getItem();
if (!world.isRemote) {
RailShape railshape = blockstate.getBlock() instanceof AbstractRailBlock ? ((AbstractRailBlock) blockstate.getBlock()).getRailDirection(blockstate, world, blockpos, null) : RailShape.NORTH_SOUTH;
double d0 = 0.0D;
if (railshape.isAscending()) {
d0 = 0.5D;
}
AbstractMinecartEntity abstractminecartentity = AbstractMinecartEntity.create(world, (double) blockpos.getX() + 0.5D, (double) blockpos.getY() + 0.0625D + d0, (double) blockpos.getZ() + 0.5D, this.minecartType);
if (itemstack.hasDisplayName()) {
abstractminecartentity.setCustomName(itemstack.getDisplayName());
}
if (CraftEventFactory.callEntityPlaceEvent(context, abstractminecartentity).isCancelled()) {
return ActionResultType.FAIL;
}
if (!world.addEntity(abstractminecartentity)) {
return ActionResultType.PASS;
}
}
itemstack.shrink(1);
return ActionResultType.SUCCESS;
return true;
}
}
}

View File

@ -14,6 +14,7 @@ import net.minecraft.util.Hand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@ -29,7 +30,7 @@ public class SnowballItemMixin extends Item {
* @reason
*/
@Overwrite
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
public @NotNull ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, @NotNull Hand handIn) {
ItemStack itemstack = playerIn.getHeldItem(handIn);
if (!worldIn.isRemote) {
SnowballEntity snowballentity = new SnowballEntity(worldIn, playerIn);
@ -38,8 +39,8 @@ public class SnowballItemMixin extends Item {
if (!playerIn.abilities.isCreativeMode) {
itemstack.shrink(1);
}
worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
snowballentity.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
worldIn.playSound(null, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
snowballentity.func_234612_a_(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
} else if (playerIn instanceof ServerPlayerEntity) {
((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity().updateInventory();
}

View File

@ -0,0 +1,26 @@
package io.izzel.arclight.common.mixin.core.item;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SpawnEggItem;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.server.ServerWorld;
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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Optional;
@Mixin(SpawnEggItem.class)
public class SpawnEggItemMixin {
@Inject(method = "func_234809_a_", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;func_242417_l(Lnet/minecraft/entity/Entity;)V"))
private void arclight$reason(PlayerEntity p_234809_1_, MobEntity p_234809_2_, EntityType<? extends MobEntity> p_234809_3_, ServerWorld world, Vector3d p_234809_5_, ItemStack p_234809_6_, CallbackInfoReturnable<Optional<MobEntity>> cir) {
((WorldBridge) world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
}
}

View File

@ -2,6 +2,7 @@ package io.izzel.arclight.common.mixin.core.item;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import io.izzel.arclight.common.bridge.entity.projectile.TridentEntityBridge;
import io.izzel.arclight.mixin.Eject;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
@ -29,27 +30,19 @@ public class TridentItemMixin {
if (j != 0) stack.damageItem(amount, entityIn, onBroken);
}
private transient boolean arclight$success;
@Inject(method = "onPlayerStoppedUsing", cancellable = true, at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
public void arclight$returnIfFail(ItemStack stack, World worldIn, LivingEntity entityLiving, int timeLeft, CallbackInfo ci) {
if (!arclight$success) {
ci.cancel();
}
}
@Redirect(method = "onPlayerStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
public boolean arclight$addEntity(World world, Entity entityIn, ItemStack stack, World worldIn, LivingEntity entityLiving, int timeLeft) {
@Eject(method = "onPlayerStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
public boolean arclight$addEntity(World world, Entity entityIn, CallbackInfo ci, ItemStack stack, World worldIn, LivingEntity entityLiving, int timeLeft) {
if (!world.addEntity(entityIn)) {
if (entityLiving instanceof ServerPlayerEntity) {
((ServerPlayerEntityBridge) entityLiving).bridge$getBukkitEntity().updateInventory();
}
return arclight$success = false;
ci.cancel();
return false;
}
stack.damageItem(1, entityLiving, (entity) ->
entity.sendBreakAnimation(entityLiving.getActiveHand()));
((TridentEntityBridge) entityIn).bridge$setThrownStack(stack.copy());
return arclight$success = true;
return true;
}
@Inject(method = "onPlayerStoppedUsing", at = @At(value = "FIELD", ordinal = 1, target = "Lnet/minecraft/entity/player/PlayerEntity;rotationYaw:F"))

View File

@ -1,27 +0,0 @@
package io.izzel.arclight.common.mixin.core.item.crafting;
import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.ArmorDyeRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.SpecialRecipe;
import net.minecraft.util.ResourceLocation;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.spongepowered.asm.mixin.Mixin;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
@Mixin(ArmorDyeRecipe.class)
public abstract class ArmorDyeRecipeMixin extends SpecialRecipe implements IRecipeBridge {
public ArmorDyeRecipeMixin(ResourceLocation idIn) {
super(idIn);
}
@Override
public Recipe bridge$toBukkitRecipe() {
return ArclightSpecialRecipe.shapeless(new ItemStack(Material.LEATHER_HELMET), this,
Ingredient.fromItems(Items.BONE_MEAL));
}
}

View File

@ -1,27 +0,0 @@
package io.izzel.arclight.common.mixin.core.item.crafting;
import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.BannerDuplicateRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.SpecialRecipe;
import net.minecraft.util.ResourceLocation;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.spongepowered.asm.mixin.Mixin;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
@Mixin(BannerDuplicateRecipe.class)
public abstract class BannerDuplicateRecipeMixin extends SpecialRecipe implements IRecipeBridge {
public BannerDuplicateRecipeMixin(ResourceLocation idIn) {
super(idIn);
}
@Override
public Recipe bridge$toBukkitRecipe() {
return ArclightSpecialRecipe.shapeless(new ItemStack(Material.WHITE_BANNER), this,
Ingredient.fromItems(Items.WHITE_BANNER));
}
}

View File

@ -1,21 +0,0 @@
package io.izzel.arclight.common.mixin.core.item.crafting;
import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.BookCloningRecipe;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(BookCloningRecipe.class)
public class BookCloningRecipeMixin implements IRecipeBridge {
@Override
public Recipe bridge$toBukkitRecipe() {
return ArclightSpecialRecipe.shapeless(new ItemStack(Material.WRITTEN_BOOK), (IRecipe<?>) this, Ingredient.fromItems(Items.WRITTEN_BOOK));
}
}

View File

@ -1,27 +0,0 @@
package io.izzel.arclight.common.mixin.core.item.crafting;
import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.FireworkRocketRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.SpecialRecipe;
import net.minecraft.util.ResourceLocation;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.spongepowered.asm.mixin.Mixin;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
@Mixin(FireworkRocketRecipe.class)
public abstract class FireworkRocketRecipeMixin extends SpecialRecipe implements IRecipeBridge {
public FireworkRocketRecipeMixin(ResourceLocation idIn) {
super(idIn);
}
@Override
public Recipe bridge$toBukkitRecipe() {
return ArclightSpecialRecipe.shapeless(new ItemStack(Material.FIREWORK_ROCKET, 3), this,
Ingredient.fromItems(Items.GUNPOWDER));
}
}

View File

@ -1,27 +0,0 @@
package io.izzel.arclight.common.mixin.core.item.crafting;
import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.FireworkStarFadeRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.SpecialRecipe;
import net.minecraft.util.ResourceLocation;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.spongepowered.asm.mixin.Mixin;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
@Mixin(FireworkStarFadeRecipe.class)
public abstract class FireworkStarFadeRecipeMixin extends SpecialRecipe implements IRecipeBridge {
public FireworkStarFadeRecipeMixin(ResourceLocation idIn) {
super(idIn);
}
@Override
public Recipe bridge$toBukkitRecipe() {
return ArclightSpecialRecipe.shapeless(new ItemStack(Material.FIREWORK_STAR), this,
Ingredient.fromItems(Items.FIREWORK_STAR, Items.BONE_MEAL));
}
}

View File

@ -1,27 +0,0 @@
package io.izzel.arclight.common.mixin.core.item.crafting;
import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.FireworkStarRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.SpecialRecipe;
import net.minecraft.util.ResourceLocation;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.spongepowered.asm.mixin.Mixin;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
@Mixin(FireworkStarRecipe.class)
public abstract class FireworkStarRecipeMixin extends SpecialRecipe implements IRecipeBridge {
public FireworkStarRecipeMixin(ResourceLocation idIn) {
super(idIn);
}
@Override
public Recipe bridge$toBukkitRecipe() {
return ArclightSpecialRecipe.shapeless(new ItemStack(Material.FIREWORK_STAR), this,
Ingredient.fromItems(Items.GUNPOWDER));
}
}

View File

@ -4,7 +4,6 @@ import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import org.bukkit.craftbukkit.v.inventory.CraftItemStack;
import org.bukkit.inventory.Recipe;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -22,6 +21,6 @@ public interface IRecipeMixin extends IRecipeBridge {
@Override
default Recipe bridge$toBukkitRecipe() {
return ArclightSpecialRecipe.shapeless(CraftItemStack.asCraftMirror(getRecipeOutput()), (IRecipe<?>) this);
return new ArclightSpecialRecipe((IRecipe<?>) this);
}
}

View File

@ -3,7 +3,6 @@ package io.izzel.arclight.common.mixin.core.item.crafting;
import io.izzel.arclight.common.bridge.item.crafting.IngredientBridge;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@ -14,7 +13,6 @@ import javax.annotation.Nullable;
public abstract class IngredientMixin implements IngredientBridge {
// @formatter:off
@Shadow @Final private Ingredient.IItemList[] acceptedItems;
@Shadow public abstract void determineMatchingStacks();
@Shadow public ItemStack[] matchingStacks;
// @formatter:on
@ -29,24 +27,25 @@ public abstract class IngredientMixin implements IngredientBridge {
public boolean test(@Nullable ItemStack stack) {
if (stack == null) {
return false;
} else if (this.acceptedItems.length == 0) {
return stack.isEmpty();
} else {
this.determineMatchingStacks();
for (ItemStack itemstack : this.matchingStacks) {
if (exact) {
if (itemstack.getItem() == stack.getItem() && ItemStack.areItemsEqual(itemstack, stack)) {
if (this.matchingStacks.length == 0) {
return stack.isEmpty();
} else {
for (ItemStack itemstack : this.matchingStacks) {
if (exact) {
if (itemstack.getItem() == stack.getItem() && ItemStack.areItemsEqual(itemstack, stack)) {
return true;
}
continue;
}
if (itemstack.getItem() == stack.getItem()) {
return true;
}
continue;
}
if (itemstack.getItem() == stack.getItem()) {
return true;
}
}
return false;
return false;
}
}
}

View File

@ -1,27 +0,0 @@
package io.izzel.arclight.common.mixin.core.item.crafting;
import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.MapCloningRecipe;
import net.minecraft.item.crafting.SpecialRecipe;
import net.minecraft.util.ResourceLocation;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.spongepowered.asm.mixin.Mixin;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
@Mixin(MapCloningRecipe.class)
public abstract class MapCloningRecipeMixin extends SpecialRecipe implements IRecipeBridge {
public MapCloningRecipeMixin(ResourceLocation idIn) {
super(idIn);
}
@Override
public Recipe bridge$toBukkitRecipe() {
return ArclightSpecialRecipe.shapeless(new ItemStack(Material.MAP), this,
Ingredient.fromItems(Items.MAP));
}
}

View File

@ -1,27 +0,0 @@
package io.izzel.arclight.common.mixin.core.item.crafting;
import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.RepairItemRecipe;
import net.minecraft.item.crafting.SpecialRecipe;
import net.minecraft.util.ResourceLocation;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.spongepowered.asm.mixin.Mixin;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
@Mixin(RepairItemRecipe.class)
public abstract class RepairItemRecipeMixin extends SpecialRecipe implements IRecipeBridge {
public RepairItemRecipeMixin(ResourceLocation idIn) {
super(idIn);
}
@Override
public Recipe bridge$toBukkitRecipe() {
return ArclightSpecialRecipe.shapeless(new ItemStack(Material.LEATHER_HELMET), this,
Ingredient.fromItems(Items.LEATHER_HELMET));
}
}

View File

@ -1,27 +0,0 @@
package io.izzel.arclight.common.mixin.core.item.crafting;
import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.ShieldRecipes;
import net.minecraft.item.crafting.SpecialRecipe;
import net.minecraft.util.ResourceLocation;
import org.bukkit.craftbukkit.v.inventory.CraftItemStack;
import org.bukkit.inventory.Recipe;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(ShieldRecipes.class)
public abstract class ShieldRecipesMixin extends SpecialRecipe implements IRecipeBridge {
public ShieldRecipesMixin(ResourceLocation idIn) {
super(idIn);
}
@Override
public Recipe bridge$toBukkitRecipe() {
return ArclightSpecialRecipe.shapeless(CraftItemStack.asCraftMirror(new ItemStack(Items.SHIELD)), this,
Ingredient.fromItems(Items.WHITE_BANNER));
}
}

View File

@ -1,28 +0,0 @@
package io.izzel.arclight.common.mixin.core.item.crafting;
import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.ShulkerBoxColoringRecipe;
import net.minecraft.item.crafting.SpecialRecipe;
import net.minecraft.util.ResourceLocation;
import org.bukkit.craftbukkit.v.inventory.CraftItemStack;
import org.bukkit.inventory.Recipe;
import org.spongepowered.asm.mixin.Mixin;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
@Mixin(ShulkerBoxColoringRecipe.class)
public abstract class ShulkerBoxColoringRecipeMixin extends SpecialRecipe implements IRecipeBridge {
public ShulkerBoxColoringRecipeMixin(ResourceLocation idIn) {
super(idIn);
}
@Override
public Recipe bridge$toBukkitRecipe() {
return ArclightSpecialRecipe.shapeless(CraftItemStack.asCraftMirror(new ItemStack(Blocks.WHITE_SHULKER_BOX)), this,
Ingredient.fromItems(Items.BONE_MEAL));
}
}

View File

@ -0,0 +1,32 @@
package io.izzel.arclight.common.mixin.core.item.crafting;
import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.SmithingRecipe;
import net.minecraft.util.ResourceLocation;
import org.bukkit.craftbukkit.v.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v.inventory.CraftRecipe;
import org.bukkit.craftbukkit.v.inventory.CraftSmithingRecipe;
import org.bukkit.craftbukkit.v.util.CraftNamespacedKey;
import org.bukkit.inventory.Recipe;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(SmithingRecipe.class)
public class SmithingRecipeMixin implements IRecipeBridge {
// @formatter:off
@Shadow @Final private ItemStack result;
@Shadow @Final private ResourceLocation recipeId;
@Shadow @Final private Ingredient base;
@Shadow @Final private Ingredient addition;
// @formatter:on
@Override
public Recipe bridge$toBukkitRecipe() {
CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
return new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.recipeId), result, CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition));
}
}

View File

@ -1,26 +0,0 @@
package io.izzel.arclight.common.mixin.core.item.crafting;
import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.SpecialRecipe;
import net.minecraft.item.crafting.SuspiciousStewRecipe;
import net.minecraft.util.ResourceLocation;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.spongepowered.asm.mixin.Mixin;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
@Mixin(SuspiciousStewRecipe.class)
public abstract class SuspiciousStewRecipeMixin extends SpecialRecipe implements IRecipeBridge {
public SuspiciousStewRecipeMixin(ResourceLocation idIn) {
super(idIn);
}
@Override
public Recipe bridge$toBukkitRecipe() {
return ArclightSpecialRecipe.shapeless(new ItemStack(Material.SUSPICIOUS_STEW), this, Ingredient.fromItems(Items.BOWL));
}
}

View File

@ -1,31 +0,0 @@
package io.izzel.arclight.common.mixin.core.item.crafting;
import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.SpecialRecipe;
import net.minecraft.item.crafting.TippedArrowRecipe;
import net.minecraft.util.ResourceLocation;
import org.bukkit.craftbukkit.v.inventory.CraftItemStack;
import org.bukkit.inventory.Recipe;
import org.spongepowered.asm.mixin.Mixin;
import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe;
@Mixin(TippedArrowRecipe.class)
public abstract class TippedArrowRecipeMixin extends SpecialRecipe implements IRecipeBridge {
public TippedArrowRecipeMixin(ResourceLocation idIn) {
super(idIn);
}
@Override
public Recipe bridge$toBukkitRecipe() {
CraftItemStack result = CraftItemStack.asCraftMirror(new ItemStack(Items.TIPPED_ARROW, 8));
return ArclightSpecialRecipe.shaped(result, this, 3,
Ingredient.fromItems(Items.ARROW), Ingredient.fromItems(Items.ARROW), Ingredient.fromItems(Items.ARROW),
Ingredient.fromItems(Items.ARROW), Ingredient.fromItems(Items.LINGERING_POTION), Ingredient.fromItems(Items.ARROW),
Ingredient.fromItems(Items.ARROW), Ingredient.fromItems(Items.ARROW), Ingredient.fromItems(Items.ARROW)
);
}
}

View File

@ -2,114 +2,35 @@ package io.izzel.arclight.common.mod.util;
import io.izzel.arclight.common.bridge.item.crafting.RecipeManagerBridge;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.SpecialRecipe;
import org.bukkit.Bukkit;
import org.bukkit.Keyed;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.v.CraftServer;
import org.bukkit.craftbukkit.v.inventory.CraftComplexRecipe;
import org.bukkit.craftbukkit.v.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v.inventory.CraftRecipe;
import org.bukkit.craftbukkit.v.inventory.CraftShapedRecipe;
import org.bukkit.craftbukkit.v.inventory.CraftShapelessRecipe;
import org.bukkit.craftbukkit.v.util.CraftNamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
import org.jetbrains.annotations.NotNull;
public class ArclightSpecialRecipe {
public class ArclightSpecialRecipe extends CraftComplexRecipe {
public static class Shapeless extends CraftShapelessRecipe {
private final IRecipe<?> recipe;
private final IRecipe<?> recipe;
public Shapeless(ItemStack result, IRecipe<?> recipe) {
super(CraftNamespacedKey.fromMinecraft(recipe.getId()), result);
this.recipe = recipe;
this.setGroup(this.recipe.getGroup());
}
@Override
public void addToCraftingManager() {
((RecipeManagerBridge) ((CraftServer) Bukkit.getServer()).getServer()
.getRecipeManager()).bridge$addRecipe(recipe);
}
public ArclightSpecialRecipe(IRecipe<?> recipe) {
super(null);
this.recipe = recipe;
}
public static class Shaped extends CraftShapedRecipe {
private final SpecialRecipe recipe;
public Shaped(ItemStack result, SpecialRecipe recipe) {
super(CraftNamespacedKey.fromMinecraft(recipe.getId()), result);
this.recipe = recipe;
this.setGroup(this.recipe.getGroup());
}
@Override
public void addToCraftingManager() {
((RecipeManagerBridge) ((CraftServer) Bukkit.getServer()).getServer()
.getRecipeManager()).bridge$addRecipe(recipe);
}
@Override
public @NotNull ItemStack getResult() {
return CraftItemStack.asCraftMirror(this.recipe.getRecipeOutput());
}
public static class Dynamic implements CraftRecipe, Keyed {
private final IRecipe<?> recipe;
public Dynamic(IRecipe<?> recipe) {
this.recipe = recipe;
}
@Override
public void addToCraftingManager() {
((RecipeManagerBridge) ((CraftServer) Bukkit.getServer()).getServer().getRecipeManager()).bridge$addRecipe(this.recipe);
}
@Override
public @NotNull ItemStack getResult() {
return CraftItemStack.asCraftMirror(this.recipe.getRecipeOutput());
}
@Override
@NotNull
public NamespacedKey getKey() {
return CraftNamespacedKey.fromMinecraft(this.recipe.getId());
}
@Override
public @NotNull NamespacedKey getKey() {
return CraftNamespacedKey.fromMinecraft(this.recipe.getId());
}
public static CraftRecipe shapeless(ItemStack result, IRecipe<?> recipe, Ingredient... ingredients) {
if (recipe.getRecipeOutput().isEmpty()) {
return new Dynamic(recipe);
}
Shapeless shapeless = new Shapeless(result, recipe);
for (Ingredient ingredient : ingredients) {
shapeless.addIngredient(CraftRecipe.toBukkit(ingredient));
}
return shapeless;
}
public static CraftShapedRecipe shaped(ItemStack result, SpecialRecipe recipe, int width, Ingredient... ingredients) {
Shaped shaped = new Shaped(result, recipe);
int height = ingredients.length / width;
String[] shape = new String[height];
char c = 'a';
for (int i = 0; i < height; i++) {
StringBuilder builder = new StringBuilder();
for (int j = 0; j < width; j++) {
builder.append(c++);
}
shape[i] = builder.toString();
}
shaped.shape(shape);
c = 'a';
for (Ingredient ingredient : ingredients) {
RecipeChoice choice = CraftRecipe.toBukkit(ingredient);
if (choice != null) {
shaped.setIngredient(c, choice);
}
c++;
}
return shaped;
@Override
public void addToCraftingManager() {
((RecipeManagerBridge) ServerLifecycleHooks.getCurrentServer().getRecipeManager()).bridge$addRecipe(this.recipe);
}
}

View File

@ -60,14 +60,12 @@
"block.GrassBlockMixin",
"block.IceBlockMixin",
"block.JukeBoxBlockMixin",
"block.KelpTopBlockMixin",
"block.LeavesBlockMixin",
"block.LecternBlockMixin",
"block.LeverBlockMixin",
"block.LilyPadBlockMixin",
"block.MagmaBlockMixin",
"block.MushroomBlockMixin",
"block.NetherPortalBlock_SizeMixin",
"block.NetherPortalBlockMixin",
"block.NetherWartBlockMixin",
"block.NoteBlockMixin",
@ -110,7 +108,6 @@
"command.arguments.EntitySelectorParserMixin",
"command.impl.EffectCommandMixin",
"command.impl.ReloadCommandMixin",
"command.impl.SummonCommandMixin",
"command.impl.TeleportCommandMixin",
"command.impl.TimeCommandMixin",
"enchantment.DamageEnchantmentMixin",
@ -299,6 +296,7 @@
"item.DyeItemMixin",
"item.EggItemMixin",
"item.EnderCrystalItemMixin",
"item.EnderEyeItemMixin",
"item.EnderPearlItemMixin",
"item.FilledMapItemMixin",
"item.FireChargeItemMixin",
@ -313,31 +311,21 @@
"item.PotionItemMixin",
"item.ShearsItemMixin",
"item.SnowballItemMixin",
"item.SpawnEggItemMixin",
"item.TridentItemMixin",
"item.crafting.ArmorDyeRecipeMixin",
"item.crafting.BannerDuplicateRecipeMixin",
"item.crafting.BlastingRecipeMixin",
"item.crafting.BookCloningRecipeMixin",
"item.crafting.CampfireCookingRecipeMixin",
"item.crafting.FireworkRocketRecipeMixin",
"item.crafting.FireworkStarFadeRecipeMixin",
"item.crafting.FireworkStarRecipeMixin",
"item.crafting.FurnaceRecipeMixin",
"item.crafting.IngredientMixin",
"item.crafting.IRecipeMixin",
"item.crafting.MapCloningRecipeMixin",
"item.crafting.RecipeManagerMixin",
"item.crafting.RepairItemRecipeMixin",
"item.crafting.ServerRecipeBookMixin",
"item.crafting.ShapedRecipeMixin",
"item.crafting.ShapelessRecipeMixin",
"item.crafting.ShieldRecipesMixin",
"item.crafting.ShulkerBoxColoringRecipeMixin",
"item.crafting.SmithingRecipeMixin",
"item.crafting.SmokingRecipeMixin",
"item.crafting.SpecialRecipeMixin",
"item.crafting.StonecuttingRecipeMixin",
"item.crafting.SuspiciousStewRecipeMixin",
"item.crafting.TippedArrowRecipeMixin",
"network.NetworkManagerMixin",
"network.PacketThreadUtilMixin",
"network.datasync.EntityDataManagerMixin",
@ -427,7 +415,6 @@
"world.storage.DerivedWorldInfoMixin",
"world.storage.MapData_MapInfoMixin",
"world.storage.MapDataMixin",
"world.storage.SaveFormat_LevelSaveMixin",
"world.storage.SaveFormatMixin",
"world.storage.SaveHandlerMixin",
"world.storage.WorldInfoMixin",

View File

@ -56,6 +56,7 @@ repositories {
maven { url = 'https://repo.codemc.io/repository/nms/' }
maven { url = 'https://files.minecraftforge.net/maven/' }
maven { url = 'https://www.dogforce-games.com/maven/' }
maven { url = 'https://jitpack.io/' }
}
def embedLibs = ['org.spongepowered:mixin:0.8', 'org.ow2.asm:asm-util:8.0.1',
@ -80,6 +81,7 @@ dependencies {
}
embed 'net.md-5:bungeecord-chat:1.16-R0.3@jar'
embed "org.spigotmc:spigot-api:$minecraftVersion-R0.1-SNAPSHOT@jar"
embed 'com.github.ArclightTeam:mixin-tools:1.0.0'
}
def getGitHash = { ->