Update README, drop 1.14

This commit is contained in:
IzzelAliz 2020-08-17 20:21:45 +08:00
parent 5106498692
commit 78be5078fa
92 changed files with 14 additions and 4629 deletions

View File

@ -2,19 +2,22 @@
A Bukkit server implementation utilizing Mixin.
[![AppVeyor](https://img.shields.io/appveyor/build/IzzelAliz/arclight?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight) ![GitHub](https://img.shields.io/github/license/IzzelAliz/Arclight?style=flat-square)
![Actions](https://img.shields.io/github/workflow/status/IzzelAliz/Arclight/Java%20CI%20with%20Gradle?style=flat-square) ![GitHub](https://img.shields.io/github/license/IzzelAliz/Arclight?style=flat-square)
| Minecraft | Forge |
| ---- | ---- |
| ![MC 1.14.4](https://img.shields.io/badge/MC-1.14.4-FF69B4?style=flat-square) | ![Forge 28.2.0](https://img.shields.io/badge/Forge-28.2.0-purple?style=flat-square) |
| ![MC 1.15.2](https://img.shields.io/badge/MC-1.15.2-6666FF?style=flat-square) | ![Forge 31.2.30](https://img.shields.io/badge/Forge-31.2.30-AA66FF?style=flat-square) |
| Minecraft | Forge | Status | Build |
| :----: | :----: | :---: | :---: |
| 1.16.x | - | - | [![1.16 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-16?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-16) |
| 1.15.x | 31.2.30 | ACTIVE | [![1.15 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-15?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-15) |
| 1.14.x | 28.2.0 | [LEGACY](https://github.com/IzzelAliz/Arclight/releases/tag/1.0.6) | [![1.14 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight) |
* Legacy version still accepts pull requests.
![](.github/arclightlogo.jpg)
## Installing
1. Download the jar from [release page](https://github.com/IzzelAliz/Arclight/releases) or [build server](https://ci.appveyor.com/project/IzzelAliz/arclight/build/artifacts).
2. Launch with command `java -jar arclight-forge-mcversion-xxx.jar nogui`. The `nogui` argument will disable the server control panel.
1. Download the jar from [release page](https://github.com/IzzelAliz/Arclight/releases) or build server. (see the table above)
2. Launch with command `java -jar arclight-forge-<mc>-<version>.jar nogui`. The `nogui` argument will disable the server control panel.
## Support

View File

@ -1,4 +1,7 @@
version: '{branch}-{build}'
branches:
only:
- 1.15
environment:
JAVA_HOME: C:\Program Files\Java\jdk1.8.0
cache:

View File

@ -1,131 +0,0 @@
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
maven { url = 'https://repo.spongepowered.org/maven' }
jcenter()
mavenCentral()
maven { url = 'https://jitpack.io' }
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
classpath "com.github.ArclightTeam:arclight-gradle-plugin:$agpVersion"
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'io.izzel.arclight'
ext {
minecraftVersion = '1.14.4'
forgeVersion = '28.2.0'
}
arclight {
mcVersion = minecraftVersion
forgeVersion = project.ext.forgeVersion
bukkitVersion = 'v1_14_R1'
wipeVersion = true
reobfVersion = true
accessTransformer = project(':arclight-common').file('bukkit.at')
}
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
configurations {
embed
compile.extendsFrom(embed)
}
minecraft {
mappings channel: 'stable', version: "58-$minecraftVersion"
accessTransformer = project(':arclight-common').file('src/main/resources/META-INF/accesstransformer.cfg')
}
repositories {
jcenter()
maven {
name = 'sponge-repo'
url = 'https://repo.spongepowered.org/maven'
}
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url = 'https://repo.codemc.io/repository/nms/' }
maven { url = 'https://files.minecraftforge.net/maven/' }
}
def embedLibs = ['org.spongepowered:mixin:0.8', 'org.ow2.asm:asm-util:6.2',
'org.ow2.asm:asm-analysis:6.2', 'org.yaml:snakeyaml:1.23',
'org.xerial:sqlite-jdbc:3.28.0', 'mysql:mysql-connector-java:5.1.47',
'commons-lang:commons-lang:2.6', 'com.googlecode.json-simple:json-simple:1.1.1',
'org.apache.logging.log4j:log4j-jul:2.11.2', 'net.md-5:SpecialSource:1.8.6',
'net.minecraftforge:eventbus:2.0.0-milestone.1:service', 'org.jline:jline-terminal-jansi:3.12.1',
'org.fusesource.jansi:jansi:1.18', 'org.jline:jline-terminal:3.12.1',
'org.jline:jline-reader:3.12.1', 'jline:jline:2.12.1']
dependencies {
minecraft "net.minecraftforge:forge:$minecraftVersion-$forgeVersion"
compile group: 'org.jetbrains', name: 'annotations', version: '19.0.0'
compile(project(':arclight-common')) {
exclude module: 'forge'
}
embed project(':i18n-config')
embed project(':forge-installer')
for (def lib : embedLibs) {
arclight lib
}
embed 'net.md-5:bungeecord-chat:1.13-SNAPSHOT@jar'
embed "org.spigotmc:spigot-api:$minecraftVersion-R0.1-SNAPSHOT@jar"
}
def getGitHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}
processResources {
filesMatching("**/mods.toml") {
expand 'version': "$minecraftVersion-${project.version}-${getGitHash()}"
}
}
jar {
manifest.attributes 'MixinConnector': 'io.izzel.arclight.impl.ArclightConnector_1_14'
manifest.attributes 'Main-Class': 'io.izzel.arclight.server.Main_1_14'
manifest.attributes 'Implementation-Title': 'Arclight'
manifest.attributes 'Implementation-Version': "arclight-$minecraftVersion-${project.version}-${getGitHash()}"
manifest.attributes 'Implementation-Vendor': 'Arclight Team'
manifest.attributes 'Implementation-Timestamp': new Date().format("yyyy-MM-dd HH:mm:ss")
from(configurations.embed.collect { it.isDirectory() ? it : zipTree(it) }) {
exclude "META-INF/MANIFEST.MF"
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
exclude "LICENSE.txt"
}
from(project(':arclight-common').tasks.jar.outputs.files.collect { it.isDirectory() ? it : zipTree(it) })
}
remapSpigotJar {
includes.add('net/minecraft/block/ChestBlock$DoubleInventory')
includes.add('net/minecraft/tileentity/LecternTileEntity$LecternInventory')
}
mixin {
add sourceSets.main, 'mixins.arclight.impl.refmap.1_14.json'
}
compileJava {
options.compilerArgs << '-XDignore.symbol.file' << '-XDenableSunApiLintControl'
options.encoding = 'UTF-8'
options.compilerArgs += [
"-AreobfTsrgFiles=${project(':arclight-common').file('extra_mapping.tsrg').canonicalPath}"
]
}

View File

@ -1,20 +0,0 @@
package io.izzel.arclight.impl;
import io.izzel.arclight.common.mod.ArclightConnector;
import io.izzel.arclight.i18n.ArclightConfig;
import org.spongepowered.asm.mixin.Mixins;
@SuppressWarnings("unused")
public class ArclightConnector_1_14 extends ArclightConnector {
@Override
public void connect() {
super.connect();
Mixins.addConfiguration("mixins.arclight.impl.core.1_14.json");
Mixins.addConfiguration("mixins.arclight.optimization.1_14.json");
if (ArclightConfig.spec().getOptimization().isRemoveStream()) {
Mixins.addConfiguration("mixins.arclight.optimization.stream.1_14.json");
}
LOGGER.info("mixin-load.optimization");
}
}

View File

@ -1,20 +0,0 @@
package io.izzel.arclight.impl;
import io.izzel.arclight.common.mod.ArclightLocator;
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
import net.minecraftforge.forgespi.locating.IModFile;
import java.io.File;
import java.net.URISyntaxException;
public class ArclightLocator_1_14 extends ArclightLocator {
@Override
protected IModFile loadJars() {
try {
return new ModFile(new File(ArclightLocator.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toPath(), this);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
}

View File

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

@ -1,14 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(Block.class)
public abstract class BlockMixin_1_14 {
// @formatter:off
@Shadow public abstract BlockState getDefaultState();
// @formatter:on
}

View File

@ -1,19 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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,28 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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_14 {
@Redirect(method = "eatCake", 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

@ -1,102 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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.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_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) {
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<Boolean> 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(true);
}
}
@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<Boolean> cir) {
int i = state.get(CauldronBlock.LEVEL);
if (!changeLevel(worldIn, pos, state, i - 1, player, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
cir.setReturnValue(true);
}
}
@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<Boolean> cir) {
int i = state.get(CauldronBlock.LEVEL);
if (!changeLevel(worldIn, pos, state, i - 1, player, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
cir.setReturnValue(true);
}
}
@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

@ -1,22 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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

@ -1,120 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.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_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,19 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CocoaBlock;
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(CocoaBlock.class)
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) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags);
}
}

View File

@ -1,31 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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.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.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_14 {
// @formatter:off
@Shadow @Final private Block deadBlock;
// @formatter:on
@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"))
public void arclight$blockFade(BlockState state, World worldIn, BlockPos pos, Random random, CallbackInfo ci) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, this.deadBlock.getDefaultState()).isCancelled()) {
ci.cancel();
}
}
}

View File

@ -1,32 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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.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.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_14 {
// @formatter:off
@Shadow @Final private Block deadBlock;
// @formatter:on
@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"))
public void arclight$blockFade(BlockState state, World worldIn, BlockPos pos, Random random, CallbackInfo ci) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, this.deadBlock.getDefaultState().with(AbstractCoralPlantBlock.WATERLOGGED, false)).isCancelled()) {
ci.cancel();
}
}
}

View File

@ -1,32 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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.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.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_14 {
// @formatter:off
@Shadow @Final private Block deadBlock;
// @formatter:on
@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"))
public void arclight$blockFade(BlockState state, World worldIn, BlockPos pos, Random random, CallbackInfo ci) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, this.deadBlock.getDefaultState().with(AbstractCoralPlantBlock.WATERLOGGED, false)).isCancelled()) {
ci.cancel();
}
}
}

View File

@ -1,35 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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.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.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_14 {
// @formatter:off
@Shadow @Final private Block deadBlock;
// @formatter:on
@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"))
public void arclight$blockFade(BlockState state, World 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

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

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

@ -1,34 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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,19 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.GrassBlock;
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(GrassBlock.class)
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) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags);
}
}

View File

@ -1,19 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.KelpTopBlock;
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(KelpTopBlock.class)
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) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, state);
}
}

View File

@ -1,28 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.LeavesBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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_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) {
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

@ -1,38 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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_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"))
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

@ -1,24 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.LilyPadBlock;
import net.minecraft.entity.Entity;
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;
@Mixin(LilyPadBlock.class)
public class LilyPadBlockMixin_1_14 {
@Inject(method = "onEntityCollision", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;destroyBlock(Lnet/minecraft/util/math/BlockPos;Z)Z"))
public void arclight$entityChangeBlock(BlockState state, World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) {
if (CraftEventFactory.callEntityChangeBlockEvent(entityIn, pos, Blocks.AIR.getDefaultState()).isCancelled()) {
ci.cancel();
}
}
}

View File

@ -1,19 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.MushroomBlock;
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(MushroomBlock.class)
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) {
return CraftEventFactory.handleBlockSpreadEvent(world, fromPos, toPos, newState, flags);
}
}

View File

@ -1,25 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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,19 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.NetherWartBlock;
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(NetherWartBlock.class)
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) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags);
}
}

View File

@ -1,19 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.block;
import io.izzel.arclight.common.bridge.block.NoteBlockBridge;
import net.minecraft.block.BlockState;
import net.minecraft.block.NoteBlock;
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.Redirect;
@Mixin(NoteBlock.class)
public abstract class NoteBlockMixin_1_14 implements NoteBlockBridge {
@Redirect(method = "onBlockActivated", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/NoteBlock;triggerNote(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)V"))
public void arclight$callNote2(NoteBlock noteBlock, World worldIn, BlockPos pos, BlockState blockState) {
this.bridge$play(worldIn, pos, blockState);
}
}

View File

@ -1,31 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ObserverBlock;
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(ObserverBlock.class)
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) {
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/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public void arclight$redstoneChange2(BlockState state, World worldIn, BlockPos pos, Random random, CallbackInfo ci) {
if (CraftEventFactory.callRedstoneChange(worldIn, pos, 0, 15).getNewCurrent() != 15) {
ci.cancel();
}
}
}

View File

@ -1,76 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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,31 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.RedstoneDiodeBlock;
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(RedstoneDiodeBlock.class)
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) {
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/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
public void arclight$turnOn(BlockState state, World worldIn, BlockPos pos, Random random, CallbackInfo ci) {
if (CraftEventFactory.callRedstoneChange(worldIn, pos, 0, 15).getNewCurrent() != 15) {
ci.cancel();
}
}
}

View File

@ -1,24 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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", 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$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,84 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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 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_14 {
// @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", cancellable = true, 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/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private void arclight$blockFade(BlockState state, World 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

@ -1,32 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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.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;
import java.util.Random;
@Mixin(ScaffoldingBlock.class)
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) {
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

@ -1,25 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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.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(SnowBlock.class)
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) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, Blocks.AIR.getDefaultState()).isCancelled()) {
ci.cancel();
}
}
}

View File

@ -1,31 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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 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_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) {
if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, Blocks.DIRT.getDefaultState()).isCancelled()) {
ci.cancel();
}
}
@Redirect(method = "tick", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
public boolean arclight$blockSpread(World world, BlockPos to, BlockState state, BlockState state1, World worldIn, BlockPos from) {
return CraftEventFactory.handleBlockSpreadEvent(world, from, to, state);
}
}

View File

@ -1,43 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.StemBlock;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Random;
@Mixin(StemBlock.class)
public class StemBlockMixin_1_14 {
private transient boolean arclight$success = false;
@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$cropGrow1(World 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/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
public void arclight$returnIfFail(BlockState state, World 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/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
public boolean arclight$cropGrow2(World world, BlockPos pos, BlockState state) {
return arclight$success = CraftEventFactory.handleBlockGrowEvent(world, pos, state);
}
@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$cropGrow3(World world, BlockPos pos, BlockState newState, int flags) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags);
}
}

View File

@ -1,19 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SugarCaneBlock;
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(SugarCaneBlock.class)
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) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, state);
}
}

View File

@ -1,33 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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 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_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) {
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

@ -1,51 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.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,128 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.block;
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.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 java.util.Random;
@Mixin(VineBlock.class)
public abstract class VineBlockMixin_1_14 extends BlockMixin_1_14 {
// @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, World worldIn, BlockPos pos, Random random) {
if (!worldIn.isRemote) {
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

@ -1,102 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.command.impl;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.network.play.ServerPlayNetHandlerBridge;
import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge;
import net.minecraft.command.CommandSource;
import net.minecraft.command.impl.TeleportCommand;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.network.play.server.SPlayerPositionLookPacket;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.server.TicketType;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v.CraftWorld;
import org.bukkit.event.entity.EntityTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import javax.annotation.Nullable;
import java.util.Set;
@Mixin(TeleportCommand.class)
public class TeleportCommandMixin_1_14 {
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
private static void func_201127_a(CommandSource source, Entity entityIn, ServerWorld worldIn, double x, double y, double z, Set<SPlayerPositionLookPacket.Flags> relativeList, float yaw, float pitch, @Nullable TeleportCommand.Facing facing) {
if (entityIn instanceof ServerPlayerEntity) {
ChunkPos chunkpos = new ChunkPos(new BlockPos(x, y, z));
worldIn.getChunkProvider().func_217228_a(TicketType.POST_TELEPORT, chunkpos, 1, entityIn.getEntityId());
entityIn.stopRiding();
if (((ServerPlayerEntity) entityIn).isSleeping()) {
((ServerPlayerEntity) entityIn).wakeUpPlayer(true, true, false);
}
((ServerPlayNetHandlerBridge) ((ServerPlayerEntity) entityIn).connection).bridge$pushTeleportCause(PlayerTeleportEvent.TeleportCause.COMMAND);
if (worldIn == entityIn.world) {
((ServerPlayerEntity) entityIn).connection.setPlayerLocation(x, y, z, yaw, pitch, relativeList);
} else {
((ServerPlayerEntity) entityIn).func_200619_a(worldIn, x, y, z, yaw, pitch);
}
entityIn.setRotationYawHead(yaw);
} else {
float f1 = MathHelper.wrapDegrees(yaw);
float f = MathHelper.wrapDegrees(pitch);
f = MathHelper.clamp(f, -90.0F, 90.0F);
Location to = new Location(((ServerWorldBridge) worldIn).bridge$getWorld(), x, y, z, f1, f);
EntityTeleportEvent event = new EntityTeleportEvent(((EntityBridge) entityIn).bridge$getBukkitEntity(), ((EntityBridge) entityIn).bridge$getBukkitEntity().getLocation(), to);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
to = event.getTo();
x = to.getX();
y = to.getY();
z = to.getZ();
f1 = to.getYaw();
f = to.getPitch();
worldIn = ((CraftWorld) to.getWorld()).getHandle();
if (worldIn == entityIn.world) {
entityIn.setLocationAndAngles(x, y, z, f1, f);
entityIn.setRotationYawHead(f1);
} else {
entityIn.detach();
entityIn.dimension = worldIn.dimension.getType();
Entity entity = entityIn;
entityIn = entityIn.getType().create(worldIn);
if (entityIn == null) {
return;
}
entityIn.copyDataFromOld(entity);
entityIn.setLocationAndAngles(x, y, z, f1, f);
entityIn.setRotationYawHead(f1);
worldIn.func_217460_e(entityIn);
entity.removed = true;
}
}
if (facing != null) {
facing.updateLook(source, entityIn);
}
if (!(entityIn instanceof LivingEntity) || !((LivingEntity) entityIn).isElytraFlying()) {
entityIn.setMotion(entityIn.getMotion().mul(1.0D, 0.0D, 1.0D));
entityIn.onGround = true;
}
}
}

View File

@ -1,52 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.enchantment;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.FlowingFluidBlock;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.FrostWalkerEnchantment;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.world.World;
import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.event.ForgeEventFactory;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@Mixin(FrostWalkerEnchantment.class)
public class FrostWalkerEnchantmentMixin_1_14 {
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public static void freezeNearby(LivingEntity living, World worldIn, BlockPos pos, int level) {
if (living.onGround) {
BlockState blockstate = Blocks.FROSTED_ICE.getDefaultState();
float f = (float) Math.min(16, 2 + level);
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (BlockPos blockpos : BlockPos.getAllInBoxMutable(pos.add((double) (-f), -1.0D, (double) (-f)), pos.add((double) f, -1.0D, (double) f))) {
if (blockpos.withinDistance(living.getPositionVec(), (double) f)) {
blockpos$mutableblockpos.setPos(blockpos.getX(), blockpos.getY() + 1, blockpos.getZ());
BlockState blockstate1 = worldIn.getBlockState(blockpos$mutableblockpos);
if (blockstate1.isAir(worldIn, blockpos$mutableblockpos)) {
BlockState blockstate2 = worldIn.getBlockState(blockpos);
boolean isFull = blockstate2.getBlock() == Blocks.WATER && blockstate2.get(FlowingFluidBlock.LEVEL) == 0; //TODO: Forge, modded waters?
if (blockstate2.getMaterial() == Material.WATER && isFull && blockstate.isValidPosition(worldIn, blockpos) && worldIn.func_217350_a(blockstate, blockpos, ISelectionContext.dummy()) && !ForgeEventFactory.onBlockPlace(living, new BlockSnapshot(worldIn, blockpos, blockstate2), Direction.UP)) {
if (CraftEventFactory.handleBlockFormEvent(worldIn, blockpos, blockstate, living)) {
worldIn.getPendingBlockTicks().scheduleTick(blockpos, Blocks.FROSTED_ICE, MathHelper.nextInt(living.getRNG(), 60, 120));
}
}
}
}
}
}
}
}

View File

@ -1,206 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.entity.InternalEntityBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge;
import net.minecraft.block.pattern.BlockPattern;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.MoverType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Direction;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.Heightmap;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.ForgeHooks;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v.CraftWorld;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.entity.EntityPortalEvent;
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
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;
import javax.annotation.Nullable;
import java.util.Random;
@Mixin(Entity.class)
public abstract class EntityMixin_1_14 implements EntityBridge {
// @formatter:off
@Shadow public World world;
@Shadow @Deprecated public boolean removed;
@Shadow public DimensionType dimension;
@Shadow public double posX;
@Shadow public double posZ;
@Shadow public double posY;
@Shadow @Nullable public abstract MinecraftServer getServer();
@Shadow public abstract Vec3d getMotion();
@Shadow public abstract Vec3d getLastPortalVec();
@Shadow public abstract boolean isAlive();
@Shadow public abstract Direction getTeleportDirection();
@Shadow public abstract void detach();
@Shadow public abstract EntityType<?> getType();
@Shadow(remap = false) public abstract void remove(boolean keepData);
@Shadow @Final protected EntityDataManager dataManager;
@Shadow public abstract boolean isInvisible();
@Shadow @Final protected Random rand;
@Shadow public abstract float getWidth();
@Shadow public abstract float getHeight();
@Shadow public abstract float getEyeHeight();
@Shadow public int ticksExisted;
@Shadow public abstract double getDistanceSq(Entity entityIn);
@Shadow public abstract AxisAlignedBB getBoundingBox();
@Shadow public abstract boolean isInvulnerableTo(DamageSource source);
@Shadow public float rotationPitch;
@Shadow public float rotationYaw;
@Shadow public abstract void setLocationAndAngles(double x, double y, double z, float yaw, float pitch);
@Shadow public abstract void setMotion(Vec3d motionIn);
@Shadow public abstract void setWorld(World worldIn);
@Shadow public abstract int getEntityId();
@Shadow public boolean collidedHorizontally;
@Shadow protected abstract Vec3d getAllowedMovement(Vec3d vec);
// @formatter:on
@Inject(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;canTriggerWalking()Z"))
private void arclight$move$blockCollide(MoverType typeIn, Vec3d pos, CallbackInfo ci) {
if (collidedHorizontally && this.bridge$getBukkitEntity() instanceof Vehicle) {
Vehicle vehicle = (Vehicle) this.bridge$getBukkitEntity();
org.bukkit.block.Block block = ((WorldBridge) this.world).bridge$getWorld().getBlockAt(MathHelper.floor(this.posX), MathHelper.floor(this.posY), MathHelper.floor(this.posZ));
Vec3d vec3d = this.getAllowedMovement(pos);
if (pos.x > vec3d.x) {
block = block.getRelative(BlockFace.EAST);
} else if (vec3d.x < vec3d.x) {
block = block.getRelative(BlockFace.WEST);
} else if (pos.z > vec3d.z) {
block = block.getRelative(BlockFace.SOUTH);
} else if (pos.z < vec3d.z) {
block = block.getRelative(BlockFace.NORTH);
}
if (block.getType() != org.bukkit.Material.AIR) {
VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, block);
Bukkit.getPluginManager().callEvent(event);
}
}
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
@Nullable
public Entity changeDimension(DimensionType destination) {
BlockPos location = ((InternalEntityBridge) this).internal$capturedPos();
if (!ForgeHooks.onTravelToDimension((Entity) (Object) this, destination)) return null;
if (!this.world.isRemote && !this.removed) {
this.world.getProfiler().startSection("changeDimension");
MinecraftServer minecraftserver = this.getServer();
DimensionType dimensiontype = this.dimension;
ServerWorld serverworld = minecraftserver.func_71218_a(dimensiontype);
ServerWorld serverworld1 = minecraftserver.func_71218_a(destination);
if (serverworld1 == null) {
return null;
}
// this.dimension = destination;
// this.detach();
this.world.getProfiler().startSection("reposition");
Vec3d vec3d = this.getMotion();
float f = 0.0F;
BlockPos blockpos = location;
if (blockpos == null) {
if (dimensiontype == DimensionType.THE_END && destination == DimensionType.OVERWORLD) {
blockpos = serverworld1.getHeight(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, serverworld1.getSpawnPoint());
} else if (destination == DimensionType.THE_END) {
blockpos = serverworld1.getSpawnCoordinate();
} else {
double movementFactor = serverworld.getDimension().getMovementFactor() / serverworld1.getDimension().getMovementFactor();
double d0 = this.posX * movementFactor;
double d1 = this.posZ * movementFactor;
double d3 = Math.min(-2.9999872E7D, serverworld1.getWorldBorder().minX() + 16.0D);
double d4 = Math.min(-2.9999872E7D, serverworld1.getWorldBorder().minZ() + 16.0D);
double d5 = Math.min(2.9999872E7D, serverworld1.getWorldBorder().maxX() - 16.0D);
double d6 = Math.min(2.9999872E7D, serverworld1.getWorldBorder().maxZ() - 16.0D);
d0 = MathHelper.clamp(d0, d3, d5);
d1 = MathHelper.clamp(d1, d4, d6);
Vec3d vec3d1 = this.getLastPortalVec();
blockpos = new BlockPos(d0, this.posY, d1);
BlockPattern.PortalInfo blockpattern$portalinfo = serverworld1.getDefaultTeleporter().placeInExistingPortal(blockpos, vec3d, this.getTeleportDirection(), vec3d1.x, vec3d1.y, (Object) this instanceof PlayerEntity);
if (blockpattern$portalinfo == null) {
return null;
}
blockpos = new BlockPos(blockpattern$portalinfo.pos);
vec3d = blockpattern$portalinfo.motion;
f = (float) blockpattern$portalinfo.rotation;
}
}
if (location == null) {
Location enter = ((InternalEntityBridge) this).internal$getBukkitEntity().getLocation();
Location exit = new Location(((ServerWorldBridge) serverworld1).bridge$getWorld(), blockpos.getX(), blockpos.getY(), blockpos.getZ());
EntityPortalEvent event = new EntityPortalEvent(((InternalEntityBridge) this).internal$getBukkitEntity(), enter, exit);
event.getEntity().getServer().getPluginManager().callEvent(event);
if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !this.isAlive()) {
return null;
}
exit = event.getTo();
serverworld1 = ((CraftWorld) exit.getWorld()).getHandle();
blockpos = new BlockPos(exit.getX(), exit.getY(), exit.getZ());
}
this.dimension = destination;
this.detach();
this.world.getProfiler().endStartSection("reloading");
Entity entity = this.getType().create(serverworld1);
if (entity != null) {
entity.copyDataFromOld((Entity) (Object) this);
entity.moveToBlockPosAndAngles(blockpos, entity.rotationYaw + f, entity.rotationPitch);
entity.setMotion(vec3d);
serverworld1.func_217460_e(entity);
((InternalEntityBridge) this).internal$getBukkitEntity().setHandle(entity);
((EntityBridge) entity).bridge$setBukkitEntity(((InternalEntityBridge) this).internal$getBukkitEntity());
if ((Object) this instanceof MobEntity) {
((MobEntity) (Object) this).clearLeashed(true, false);
}
}
this.remove(false);
this.world.getProfiler().endSection();
serverworld.resetUpdateEntityTick();
serverworld1.resetUpdateEntityTick();
this.world.getProfiler().endSection();
return entity;
} else {
return null;
}
}
@Override
public double bridge$getEyeHeight() {
return this.posY + (double) this.getEyeHeight();
}
}

View File

@ -1,289 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.mojang.datafixers.util.Either;
import io.izzel.arclight.common.bridge.entity.LivingEntityBridge;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.attributes.IAttribute;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import net.minecraft.entity.boss.WitherEntity;
import net.minecraft.entity.item.ExperienceOrbEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.GameRules;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.PotionEvent;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.EntityPotionEffectEvent;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@Mixin(LivingEntity.class)
public abstract class LivingEntityMixin_1_14 extends EntityMixin_1_14 implements LivingEntityBridge {
// @formatter:off
@Shadow @Final private static DataParameter<Integer> POTION_EFFECTS;
@Shadow @Final private static DataParameter<Boolean> HIDE_PARTICLES;
@Shadow @Final public Map<Effect, EffectInstance> activePotionsMap;
@Shadow public boolean potionsNeedUpdate;
@Shadow protected abstract void onFinishedPotionEffect(EffectInstance effect);
@Shadow protected abstract void onChangedPotionEffect(EffectInstance id, boolean reapply);
@Shadow protected abstract void updatePotionMetadata();
@Shadow public abstract boolean removePotionEffect(Effect effectIn);
@Shadow public abstract boolean isPotionApplicable(EffectInstance potioneffectIn);
@Shadow protected abstract void onNewPotionEffect(EffectInstance id);
@Shadow @Nullable public abstract EffectInstance removeActivePotionEffect(@Nullable Effect potioneffectin);
@Shadow public int deathTime;
@Shadow protected abstract boolean isPlayer();
@Shadow protected int recentlyHit;
@Shadow protected abstract boolean canDropLoot();
@Shadow public abstract void heal(float healAmount);
@Shadow public abstract boolean canEntityBeSeen(Entity entityIn);
@Shadow public abstract float getHealth();
@Shadow public abstract float getMaxHealth();
@Shadow public abstract boolean isSleeping();
@Shadow public abstract Collection<EffectInstance> getActivePotionEffects();
@Shadow public abstract IAttributeInstance getAttribute(IAttribute attribute);
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@SuppressWarnings("ConstantConditions")
@Overwrite
protected void onDeathUpdate() {
++this.deathTime;
if (this.deathTime >= 20 && !this.removed) {
if (!this.world.isRemote && (this.isPlayer() || this.recentlyHit > 0 && this.canDropLoot() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT))) {
int i = this.bridge$getExpToDrop();
while (i > 0) {
int j = ExperienceOrbEntity.getXPSplit(i);
i -= j;
this.world.addEntity(new ExperienceOrbEntity(this.world, this.posX, this.posY, this.posZ, j));
}
this.bridge$setExpToDrop(0);
}
this.remove((Object) this instanceof ServerPlayerEntity); //Forge keep data until we revive player
for (int k = 0; k < 20; ++k) {
double d2 = this.rand.nextGaussian() * 0.02D;
double d0 = this.rand.nextGaussian() * 0.02D;
double d1 = this.rand.nextGaussian() * 0.02D;
this.world.addParticle(ParticleTypes.POOF, this.posX + (double) (this.rand.nextFloat() * this.getWidth() * 2.0F) - (double) this.getWidth(), this.posY + (double) (this.rand.nextFloat() * this.getHeight()), this.posZ + (double) (this.rand.nextFloat() * this.getWidth() * 2.0F) - (double) this.getWidth(), d2, d0, d1);
}
}
}
private boolean isTickingEffects = false;
private List<Map.Entry<Either<EffectInstance, Effect>, EntityPotionEffectEvent.Cause>> effectsToProcess = Lists.newArrayList();
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
protected void updatePotionEffects() {
this.isTickingEffects = true;
Iterator<Effect> iterator = this.activePotionsMap.keySet().iterator();
try {
while (iterator.hasNext()) {
Effect effect = iterator.next();
EffectInstance effectinstance = this.activePotionsMap.get(effect);
if (!effectinstance.tick((LivingEntity) (Object) this)) {
if (!this.world.isRemote && !MinecraftForge.EVENT_BUS.post(new PotionEvent.PotionExpiryEvent((LivingEntity) (Object) this, effectinstance))) {
EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent((LivingEntity) (Object) this, effectinstance, null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.EXPIRATION);
if (event.isCancelled()) {
continue;
}
iterator.remove();
this.onFinishedPotionEffect(effectinstance);
}
} else if (effectinstance.getDuration() % 600 == 0) {
this.onChangedPotionEffect(effectinstance, false);
}
}
} catch (ConcurrentModificationException ignored) {
}
isTickingEffects = false;
for (Map.Entry<Either<EffectInstance, Effect>, EntityPotionEffectEvent.Cause> e : effectsToProcess) {
Either<EffectInstance, Effect> either = e.getKey();
EntityPotionEffectEvent.Cause cause = e.getValue();
bridge$pushEffectCause(cause);
if (either.left().isPresent()) {
addPotionEffect(either.left().get());
} else {
removePotionEffect(either.right().get());
}
}
effectsToProcess.clear();
if (this.potionsNeedUpdate) {
if (!this.world.isRemote) {
this.updatePotionMetadata();
}
this.potionsNeedUpdate = false;
}
int i = this.dataManager.get(POTION_EFFECTS);
boolean flag1 = this.dataManager.get(HIDE_PARTICLES);
if (i > 0) {
boolean flag;
if (this.isInvisible()) {
flag = this.rand.nextInt(15) == 0;
} else {
flag = this.rand.nextBoolean();
}
if (flag1) {
flag &= this.rand.nextInt(5) == 0;
}
if (flag && i > 0) {
double d0 = (double) (i >> 16 & 255) / 255.0D;
double d1 = (double) (i >> 8 & 255) / 255.0D;
double d2 = (double) (i >> 0 & 255) / 255.0D;
this.world.addParticle(flag1 ? ParticleTypes.AMBIENT_ENTITY_EFFECT : ParticleTypes.ENTITY_EFFECT, this.posX + (this.rand.nextDouble() - 0.5D) * (double) this.getWidth(), this.posY + this.rand.nextDouble() * (double) this.getHeight(), this.posZ + (this.rand.nextDouble() - 0.5D) * (double) this.getWidth(), d0, d1, d2);
}
}
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public boolean addPotionEffect(EffectInstance effectInstanceIn) {
EntityPotionEffectEvent.Cause cause = bridge$getEffectCause().orElse(EntityPotionEffectEvent.Cause.UNKNOWN);
if (isTickingEffects) {
effectsToProcess.add(Maps.immutableEntry(Either.left(effectInstanceIn), cause));
return true;
}
if (!this.isPotionApplicable(effectInstanceIn)) {
return false;
} else {
EffectInstance effectinstance = this.activePotionsMap.get(effectInstanceIn.getPotion());
boolean override = false;
if (effectinstance != null) {
override = new EffectInstance(effectinstance).combine(effectInstanceIn);
}
EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent((LivingEntity) (Object) this, effectinstance, effectInstanceIn, cause, override);
if (event.isCancelled()) {
return false;
}
MinecraftForge.EVENT_BUS.post(new PotionEvent.PotionAddedEvent((LivingEntity) (Object) this, effectinstance, effectInstanceIn));
if (effectinstance == null) {
this.activePotionsMap.put(effectInstanceIn.getPotion(), effectInstanceIn);
this.onNewPotionEffect(effectInstanceIn);
return true;
} else if (event.isOverride()) {
effectinstance.combine(effectInstanceIn);
this.onChangedPotionEffect(effectinstance, true);
return true;
} else {
return false;
}
}
}
@SuppressWarnings("unused") // mock
public EffectInstance c(@Nullable Effect potioneffectin, EntityPotionEffectEvent.Cause cause) {
bridge$pushEffectCause(cause);
return removeActivePotionEffect(potioneffectin);
}
@Inject(method = "removeActivePotionEffect", cancellable = true, at = @At("HEAD"))
public void arclight$clearActive(Effect effect, CallbackInfoReturnable<EffectInstance> cir) {
EntityPotionEffectEvent.Cause cause = bridge$getEffectCause().orElse(EntityPotionEffectEvent.Cause.UNKNOWN);
if (isTickingEffects) {
effectsToProcess.add(Maps.immutableEntry(Either.right(effect), cause));
cir.setReturnValue(null);
return;
}
EffectInstance effectInstance = this.activePotionsMap.get(effect);
if (effectInstance == null) {
cir.setReturnValue(null);
return;
}
EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent((LivingEntity) (Object) this, effectInstance, null, cause);
if (event.isCancelled()) {
cir.setReturnValue(null);
}
}
private transient boolean arclight$fallSuccess;
@Inject(method = "fall", cancellable = true, at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/entity/LivingEntity;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z"))
public void arclight$fall(float distance, float damageMultiplier, CallbackInfo ci) {
if (!arclight$fallSuccess) {
ci.cancel();
}
}
@Redirect(method = "fall", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z"))
public boolean arclight$fall(LivingEntity livingEntity, DamageSource source, float amount) {
return arclight$fallSuccess = livingEntity.attackEntityFrom(source, amount);
}
@Override
public void bridge$dropExperience() {
}
@Override
public void bridge$createWitherRose(LivingEntity entity) {
if (!this.world.isRemote && entity instanceof WitherEntity) {
boolean flag3 = false;
if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.world, (ServerPlayerEntity) (Object) this)) {
BlockPos blockposition = new BlockPos(this.posX, this.posY, this.posZ);
BlockState iblockdata = Blocks.WITHER_ROSE.getDefaultState();
if (this.world.getBlockState(blockposition).isAir() && iblockdata.isValidPosition(this.world, blockposition)) {
this.world.setBlockState(blockposition, iblockdata, 3);
flag3 = true;
}
}
if (!flag3) {
ItemEntity entityitem = new ItemEntity(this.world, this.posX, this.posY, this.posZ, new ItemStack(Items.WITHER_ROSE));
this.world.addEntity(entityitem);
}
}
}
}

View File

@ -1,18 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity;
import io.izzel.arclight.common.bridge.entity.MobEntityBridge;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MobEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import javax.annotation.Nullable;
@Mixin(MobEntity.class)
public abstract class MobEntityMixin_1_14 extends LivingEntityMixin_1_14 implements MobEntityBridge {
// @formatter:off
@Shadow @Nullable public abstract LivingEntity getAttackTarget();
@Shadow protected void updateAITasks() {}
// @formatter:on
}

View File

@ -1,45 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity.ai.goal;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import net.minecraft.entity.ai.goal.FollowOwnerGoal;
import net.minecraft.entity.passive.TameableEntity;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v.entity.CraftEntity;
import org.bukkit.event.entity.EntityTeleportEvent;
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;
@Mixin(FollowOwnerGoal.class)
public class FollowOwnerGoalMixin_1_14 {
// @formatter:off
@Shadow @Final protected TameableEntity tameable;
// @formatter:on
private transient boolean arclight$cancelled;
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/TameableEntity;setLocationAndAngles(DDDFF)V"))
public void arclight$teleport(TameableEntity tameableEntity, double x, double y, double z, float yaw, float pitch) {
CraftEntity craftEntity = ((EntityBridge) this.tameable).bridge$getBukkitEntity();
Location location = new Location(craftEntity.getWorld(), x, y, z, yaw, pitch);
EntityTeleportEvent event = new EntityTeleportEvent(craftEntity, craftEntity.getLocation(), location);
Bukkit.getPluginManager().callEvent(event);
if (!(arclight$cancelled = event.isCancelled())) {
tameableEntity.setLocationAndAngles(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/pathfinding/PathNavigator;clearPath()V"))
public void arclight$returnIfFail(CallbackInfo ci) {
if (arclight$cancelled) {
ci.cancel();
}
arclight$cancelled = false;
}
}

View File

@ -1,177 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity.boss;
import io.izzel.arclight.impl.mixin.v1_14.core.entity.MobEntityMixin_1_14;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityPredicate;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.boss.WitherEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.Difficulty;
import net.minecraft.world.Explosion;
import net.minecraft.world.ServerBossInfo;
import net.minecraftforge.event.ForgeEventFactory;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
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.List;
@Mixin(WitherEntity.class)
public abstract class WitherEntityMixin_1_14 extends MobEntityMixin_1_14 {
// @formatter:off
@Shadow public abstract int getInvulTime();
@Shadow public abstract void setInvulTime(int time);
@Shadow @Final private int[] nextHeadUpdate;
@Shadow @Final private int[] idleHeadUpdates;
@Shadow protected abstract void launchWitherSkullToCoords(int p_82209_1_, double x, double y, double z, boolean invulnerable);
@Shadow public abstract int getWatchedTargetId(int head);
@Shadow public abstract void updateWatchedTargetId(int targetOffset, int newId);
@Shadow protected abstract void launchWitherSkullToEntity(int p_82216_1_, LivingEntity p_82216_2_);
@Shadow @Final private static EntityPredicate field_213798_bB;
@Shadow private int blockBreakCounter;
@Shadow @Final public ServerBossInfo bossInfo;
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
protected void updateAITasks() {
if (this.getInvulTime() > 0) {
int j1 = this.getInvulTime() - 1;
if (j1 <= 0) {
Explosion.Mode explosion$mode = ForgeEventFactory.getMobGriefingEvent(this.world, (WitherEntity) (Object) this) ? Explosion.Mode.DESTROY : Explosion.Mode.NONE;
ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.bridge$getBukkitEntity(), 7.0F, false);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.world.createExplosion((WitherEntity) (Object) this, this.posX, this.posY + (double) this.getEyeHeight(), this.posZ, event.getRadius(), event.getFire(), explosion$mode);
}
this.world.playBroadcastSound(1023, new BlockPos((WitherEntity) (Object) this), 0);
}
this.setInvulTime(j1);
if (this.ticksExisted % 10 == 0) {
bridge$pushHealReason(EntityRegainHealthEvent.RegainReason.WITHER_SPAWN);
this.heal(10.0F);
}
} else {
super.updateAITasks();
for (int i = 1; i < 3; ++i) {
if (this.ticksExisted >= this.nextHeadUpdate[i - 1]) {
this.nextHeadUpdate[i - 1] = this.ticksExisted + 10 + this.rand.nextInt(10);
if (this.world.getDifficulty() == Difficulty.NORMAL || this.world.getDifficulty() == Difficulty.HARD) {
int j3 = i - 1;
int k3 = this.idleHeadUpdates[i - 1];
this.idleHeadUpdates[j3] = this.idleHeadUpdates[i - 1] + 1;
if (k3 > 15) {
float f = 10.0F;
float f1 = 5.0F;
double d0 = MathHelper.nextDouble(this.rand, this.posX - 10.0D, this.posX + 10.0D);
double d1 = MathHelper.nextDouble(this.rand, this.posY - 5.0D, this.posY + 5.0D);
double d2 = MathHelper.nextDouble(this.rand, this.posZ - 10.0D, this.posZ + 10.0D);
this.launchWitherSkullToCoords(i + 1, d0, d1, d2, true);
this.idleHeadUpdates[i - 1] = 0;
}
}
int k1 = this.getWatchedTargetId(i);
if (k1 > 0) {
Entity entity = this.world.getEntityByID(k1);
if (entity != null && entity.isAlive() && !(this.getDistanceSq(entity) > 900.0D) && this.canEntityBeSeen(entity)) {
if (entity instanceof PlayerEntity && ((PlayerEntity) entity).abilities.disableDamage) {
this.updateWatchedTargetId(i, 0);
} else {
this.launchWitherSkullToEntity(i + 1, (LivingEntity) entity);
this.nextHeadUpdate[i - 1] = this.ticksExisted + 40 + this.rand.nextInt(20);
this.idleHeadUpdates[i - 1] = 0;
}
} else {
this.updateWatchedTargetId(i, 0);
}
} else {
List<LivingEntity> list = this.world.getTargettableEntitiesWithinAABB(LivingEntity.class, field_213798_bB, (WitherEntity) (Object) this, this.getBoundingBox().grow(20.0D, 8.0D, 20.0D));
for (int j2 = 0; j2 < 10 && !list.isEmpty(); ++j2) {
LivingEntity livingentity = list.get(this.rand.nextInt(list.size()));
if (livingentity != (Object) this && livingentity.isAlive() && this.canEntityBeSeen(livingentity)) {
if (livingentity instanceof PlayerEntity) {
if (!((PlayerEntity) livingentity).abilities.disableDamage) {
if (CraftEventFactory.callEntityTargetLivingEvent((WitherEntity) (Object) this, livingentity, EntityTargetEvent.TargetReason.CLOSEST_ENTITY).isCancelled())
continue;
this.updateWatchedTargetId(i, livingentity.getEntityId());
}
} else {
if (CraftEventFactory.callEntityTargetLivingEvent((WitherEntity) (Object) this, livingentity, EntityTargetEvent.TargetReason.CLOSEST_ENTITY).isCancelled())
continue;
this.updateWatchedTargetId(i, livingentity.getEntityId());
}
break;
}
list.remove(livingentity);
}
}
}
}
if (this.getAttackTarget() != null) {
this.updateWatchedTargetId(0, this.getAttackTarget().getEntityId());
} else {
this.updateWatchedTargetId(0, 0);
}
if (this.blockBreakCounter > 0) {
--this.blockBreakCounter;
if (this.blockBreakCounter == 0 && ForgeEventFactory.getMobGriefingEvent(this.world, (WitherEntity) (Object) this)) {
int i1 = MathHelper.floor(this.posY);
int l1 = MathHelper.floor(this.posX);
int i2 = MathHelper.floor(this.posZ);
boolean flag = false;
for (int k2 = -1; k2 <= 1; ++k2) {
for (int l2 = -1; l2 <= 1; ++l2) {
for (int j = 0; j <= 3; ++j) {
int i3 = l1 + k2;
int k = i1 + j;
int l = i2 + l2;
BlockPos blockpos = new BlockPos(i3, k, l);
BlockState blockstate = this.world.getBlockState(blockpos);
if (blockstate.canEntityDestroy(this.world, blockpos, (WitherEntity) (Object) this) && ForgeEventFactory.onEntityDestroyBlock((WitherEntity) (Object) this, blockpos, blockstate)) {
if (CraftEventFactory.callEntityChangeBlockEvent((WitherEntity) (Object) this, blockpos, Blocks.AIR.getDefaultState()).isCancelled()) {
continue;
}
flag = this.world.destroyBlock(blockpos, true) || flag;
}
}
}
}
if (flag) {
this.world.playEvent(null, 1022, new BlockPos((WitherEntity) (Object) this), 0);
}
}
}
if (this.ticksExisted % 20 == 0) {
bridge$pushHealReason(EntityRegainHealthEvent.RegainReason.REGEN);
this.heal(1.0F);
}
this.bossInfo.setPercent(this.getHealth() / this.getMaxHealth());
}
}
}

View File

@ -1,48 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity.item;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.CraftEquipmentSlot;
import org.bukkit.craftbukkit.v.inventory.CraftItemStack;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ArmorStandEntity.class)
public abstract class ArmorStandEntityMixin_1_14 {
// @formatter:off
@Shadow public abstract ItemStack getItemStackFromSlot(EquipmentSlotType slotIn);
// @formatter:on
@Inject(method = "swapItem", cancellable = true, at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;abilities:Lnet/minecraft/entity/player/PlayerAbilities;"))
public void arclight$manipulateEvent(PlayerEntity playerEntity, EquipmentSlotType slotType, ItemStack itemStack, Hand hand, CallbackInfo ci) {
ItemStack itemStack1 = this.getItemStackFromSlot(slotType);
org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemStack1);
org.bukkit.inventory.ItemStack playerHeldItem = CraftItemStack.asCraftMirror(itemStack);
Player player = ((ServerPlayerEntityBridge) playerEntity).bridge$getBukkitEntity();
ArmorStand self = (ArmorStand) ((EntityBridge) this).bridge$getBukkitEntity();
EquipmentSlot slot = CraftEquipmentSlot.getSlot(slotType);
PlayerArmorStandManipulateEvent event = new PlayerArmorStandManipulateEvent(player, self, playerHeldItem, armorStandItem, slot);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
ci.cancel();
}
}
}

View File

@ -1,37 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity.item;
import io.izzel.arclight.impl.mixin.v1_14.core.entity.EntityMixin_1_14;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.item.FallingBlockEntity;
import net.minecraft.util.math.BlockPos;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
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.LocalCapture;
@Mixin(FallingBlockEntity.class)
public abstract class FallingBlockEntityMixin_1_14 extends EntityMixin_1_14 {
@Shadow private BlockState fallTile;
@Inject(method = "tick", 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"))
private void arclight$entityChangeBlock(CallbackInfo ci, Block block, BlockPos pos) {
if (CraftEventFactory.callEntityChangeBlockEvent((FallingBlockEntity) (Object) this, pos, this.fallTile).isCancelled()) {
ci.cancel();
}
}
@Inject(method = "fall", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z"))
private void arclight$damageSource(float distance, float damageMultiplier, CallbackInfo ci) {
CraftEventFactory.entityDamage = (FallingBlockEntity) (Object) this;
}
@Inject(method = "fall", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/entity/Entity;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z"))
private void arclight$damageSourceReset(float distance, float damageMultiplier, CallbackInfo ci) {
CraftEventFactory.entityDamage = null;
}
}

View File

@ -1,18 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity.item;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ItemEntity.class)
public class ItemEntityMixin_1_14 {
@Redirect(method = "func_213858_a", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/entity/item/ItemEntity;setItem(Lnet/minecraft/item/ItemStack;)V"))
private static void arclight$setNonEmpty(ItemEntity itemEntity, ItemStack stack) {
if (!stack.isEmpty()) {
itemEntity.setItem(stack);
}
}
}

View File

@ -1,60 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity.item;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.item.LeashKnotEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.LeadItem;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.bukkit.Bukkit;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.Player;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@Mixin(LeadItem.class)
public class LeadItemMixin_1_14 {
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public static boolean attachToFence(PlayerEntity player, World worldIn, BlockPos fence) {
LeashKnotEntity leashknotentity = null;
boolean flag = false;
double d0 = 7.0D;
int i = fence.getX();
int j = fence.getY();
int k = fence.getZ();
for (MobEntity mobentity : worldIn.getEntitiesWithinAABB(MobEntity.class, new AxisAlignedBB((double) i - 7.0D, (double) j - 7.0D, (double) k - 7.0D, (double) i + 7.0D, (double) j + 7.0D, (double) k + 7.0D))) {
if (mobentity.getLeashHolder() == player) {
if (leashknotentity == null) {
leashknotentity = LeashKnotEntity.create(worldIn, fence);
HangingPlaceEvent event = new HangingPlaceEvent((Hanging) ((EntityBridge) leashknotentity).bridge$getBukkitEntity(), player != null ? (Player) ((PlayerEntityBridge) player).bridge$getBukkitEntity() : null, CraftBlock.at(worldIn, fence), BlockFace.SELF);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
leashknotentity.remove();
return false;
}
}
if (CraftEventFactory.callPlayerLeashEntityEvent(mobentity, leashknotentity, player).isCancelled()) {
continue;
}
mobentity.setLeashHolder(leashknotentity, true);
flag = true;
}
}
return flag;
}
}

View File

@ -1,39 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity.monster;
import io.izzel.arclight.common.bridge.entity.monster.EndermanEntityBridge;
import io.izzel.arclight.impl.mixin.v1_14.core.entity.MobEntityMixin_1_14;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import net.minecraft.entity.monster.EndermanEntity;
import net.minecraft.network.datasync.DataParameter;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(EndermanEntity.class)
public abstract class EndermanEntityMixin_1_14 extends MobEntityMixin_1_14 implements EndermanEntityBridge {
// @formatter:off
@Shadow private int targetChangeTime;
@Shadow @Final private static DataParameter<Boolean> SCREAMING;
@Shadow @Final private static AttributeModifier ATTACKING_SPEED_BOOST;
// @formatter:on
@Override
public void bridge$updateTarget(LivingEntity livingEntity) {
IAttributeInstance iattributeinstance = this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
if (livingEntity == null) {
this.targetChangeTime = 0;
this.dataManager.set(SCREAMING, false);
iattributeinstance.removeModifier(ATTACKING_SPEED_BOOST);
} else {
this.targetChangeTime = this.ticksExisted;
this.dataManager.set(SCREAMING, true);
if (!iattributeinstance.hasModifier(ATTACKING_SPEED_BOOST)) {
iattributeinstance.applyModifier(ATTACKING_SPEED_BOOST);
}
}
}
}

View File

@ -1,23 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity.monster;
import io.izzel.arclight.impl.mixin.v1_14.core.entity.MobEntityMixin_1_14;
import net.minecraft.entity.monster.PillagerEntity;
import net.minecraft.inventory.Inventory;
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.CallbackInfoReturnable;
@Mixin(PillagerEntity.class)
public abstract class PillagerEntityMixin_1_14 extends MobEntityMixin_1_14 {
// @formatter:off
@Shadow public abstract Inventory getInventory();
// @formatter:on
@Inject(method = "canDespawn", cancellable = true, at = @At("HEAD"))
private void arclight$nullInventory(double distanceToClosestPlayer, CallbackInfoReturnable<Boolean> cir) {
if (this.getInventory() == null) cir.setReturnValue(false);
}
}

View File

@ -1,21 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity.monster;
import io.izzel.arclight.impl.mixin.v1_14.core.entity.MobEntityMixin_1_14;
import net.minecraft.block.Blocks;
import net.minecraft.entity.monster.RavagerEntity;
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(RavagerEntity.class)
public abstract class RavagerEntityMixin_1_14 extends MobEntityMixin_1_14 {
@Redirect(method = "livingTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;destroyBlock(Lnet/minecraft/util/math/BlockPos;Z)Z"))
private boolean arclight$entityChangeBlock(World world, BlockPos pos, boolean dropBlock) {
return !CraftEventFactory.callEntityChangeBlockEvent((RavagerEntity) (Object) this, pos, Blocks.AIR.getDefaultState()).isCancelled()
&& world.destroyBlock(pos, dropBlock);
}
}

View File

@ -1,19 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity.monster;
import io.izzel.arclight.impl.mixin.v1_14.core.entity.MobEntityMixin_1_14;
import net.minecraft.entity.monster.ShulkerEntity;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.world.server.ServerWorld;
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(ShulkerEntity.class)
public abstract class ShulkerEntityMixin_1_14 extends MobEntityMixin_1_14 {
@Inject(method = "notifyDataManagerChange", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/monster/ShulkerEntity;prevPosX:D"))
private void arclight$chunkCheck(DataParameter<?> key, CallbackInfo ci) {
if (this.bridge$isValid()) ((ServerWorld) this.world).chunkCheck((ShulkerEntity) (Object) this);
}
}

View File

@ -1,15 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity.monster;
import io.izzel.arclight.impl.mixin.v1_14.core.entity.MobEntityMixin_1_14;
import net.minecraft.entity.monster.ZombieEntity;
import net.minecraft.util.DamageSource;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(ZombieEntity.class)
public abstract class ZombieEntityMixin_1_14 extends MobEntityMixin_1_14 {
// @formatter:off
@Shadow public boolean attackEntityFrom(DamageSource source, float amount) { return false; }
// @formatter:on
}

View File

@ -1,61 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity.monster;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.ZombiePigmanEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.DamageSource;
import org.bukkit.Bukkit;
import org.bukkit.entity.PigZombie;
import org.bukkit.event.entity.PigZombieAngerEvent;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ZombiePigmanEntity.class)
public abstract class ZombiePigmanEntityMixin_1_14 extends ZombieEntityMixin_1_14 {
// @formatter:off
@Shadow protected abstract boolean becomeAngryAt(Entity p_70835_1_);
@Shadow protected abstract int func_223336_ef();
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public boolean attackEntityFrom(DamageSource damagesource, float f) {
if (this.isInvulnerableTo(damagesource)) {
return false;
}
Entity entity = damagesource.getTrueSource();
boolean result = super.attackEntityFrom(damagesource, f);
if (result && entity instanceof PlayerEntity && !((PlayerEntity) entity).isCreative() && this.canEntityBeSeen(entity)) {
this.becomeAngryAt(entity);
}
return result;
}
@Inject(method = "becomeAngryAt", cancellable = true, at = @At("HEAD"))
private void arclight$anger(Entity entity, CallbackInfoReturnable<Boolean> cir) {
PigZombieAngerEvent event = new PigZombieAngerEvent((PigZombie) this.bridge$getBukkitEntity(), (entity == null) ? null : ((EntityBridge) entity).bridge$getBukkitEntity(), this.func_223336_ef());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
cir.setReturnValue(false);
} else {
arclight$capture = event.getNewAnger();
}
}
private transient int arclight$capture;
@Redirect(method = "becomeAngryAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/monster/ZombiePigmanEntity;func_223336_ef()I"))
private int arclight$useAnger(ZombiePigmanEntity pigmanEntity) {
return arclight$capture;
}
}

View File

@ -1,19 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity.passive;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.impl.mixin.v1_14.core.entity.EntityMixin_1_14;
import net.minecraft.entity.passive.OcelotEntity;
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.CallbackInfo;
@Mixin(OcelotEntity.class)
public abstract class OcelotEntityMixin_1_14 extends EntityMixin_1_14 {
@Inject(method = "func_213525_dW", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private void arclight$spawnBaby(CallbackInfo ci) {
((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.OCELOT_BABY);
}
}

View File

@ -1,22 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity.passive;
import io.izzel.arclight.common.bridge.entity.MobEntityBridge;
import net.minecraft.entity.passive.PandaEntity;
import org.bukkit.event.entity.EntityTargetEvent;
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.CallbackInfoReturnable;
@Mixin(targets = "net.minecraft.entity.passive.PandaEntity.MateGoal")
public class PandaEntity_MateGoalMixin {
@Shadow @Final private PandaEntity panda;
@Inject(method = "shouldExecute", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/PandaEntity;setAttackTarget(Lnet/minecraft/entity/LivingEntity;)V"))
private void arclight$reason(CallbackInfoReturnable<Boolean> cir) {
((MobEntityBridge) this.panda).bridge$pushGoalTargetReason(EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true);
}
}

View File

@ -1,138 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity.player;
import com.mojang.datafixers.util.Either;
import io.izzel.arclight.common.bridge.entity.InternalEntityBridge;
import io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.impl.mixin.v1_14.core.entity.LivingEntityMixin_1_14;
import net.minecraft.entity.player.PlayerAbilities;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Unit;
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.craftbukkit.v.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerBedLeaveEvent;
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.ModifyVariable;
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.Optional;
@Mixin(PlayerEntity.class)
public abstract class PlayerEntityMixin_1_14 extends LivingEntityMixin_1_14 implements PlayerEntityBridge {
// @formatter:off
@Shadow public abstract Either<PlayerEntity.SleepResult, Unit> trySleep(BlockPos at);
@Shadow public abstract void startSleeping(BlockPos p_213342_1_);
@Shadow public int sleepTimer;
@Shadow public abstract void addStat(ResourceLocation stat);
@Shadow @Final public PlayerAbilities abilities;
// @formatter:on
@Override
public CraftHumanEntity bridge$getBukkitEntity() {
return (CraftHumanEntity) ((InternalEntityBridge) this).internal$getBukkitEntity();
}
private boolean arclight$forceSleep = false;
private Object arclight$processSleep = null;
private Either<PlayerEntity.SleepResult, Unit> getBedResult(BlockPos at, Direction direction) {
arclight$processSleep = true;
Either<PlayerEntity.SleepResult, Unit> either = this.trySleep(at);
arclight$processSleep = null;
return either;
}
public Either<PlayerEntity.SleepResult, Unit> sleep(BlockPos at, boolean force) {
arclight$forceSleep = force;
try {
return this.trySleep(at);
} finally {
arclight$forceSleep = false;
}
}
@Inject(method = "trySleep", cancellable = true, at = @At(value = "HEAD"))
public void arclight$onSleep(BlockPos at, CallbackInfoReturnable<Either<PlayerEntity.SleepResult, Unit>> cir) {
if (arclight$processSleep == null) {
Either<PlayerEntity.SleepResult, Unit> result = getBedResult(at, null);
if (result.left().orElse(null) == PlayerEntity.SleepResult.OTHER_PROBLEM) {
cir.setReturnValue(result);
return;
}
if (arclight$forceSleep) {
result = Either.right(Unit.INSTANCE);
}
if (this.bridge$getBukkitEntity() instanceof Player) {
result = CraftEventFactory.callPlayerBedEnterEvent((PlayerEntity) (Object) this, at, result);
if (result.left().isPresent()) {
cir.setReturnValue(result);
return;
}
}
this.startSleeping(at);
this.sleepTimer = 0;
if (this.world instanceof ServerWorld) {
((ServerWorld) this.world).updateAllPlayersSleepingFlag();
}
cir.setReturnValue(Either.right(Unit.INSTANCE));
}
}
@Inject(method = "trySleep", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;startSleeping(Lnet/minecraft/util/math/BlockPos;)V"))
public void arclight$preSleep(BlockPos at, CallbackInfoReturnable<Either<PlayerEntity.SleepResult, Unit>> cir) {
if (arclight$processSleep != null) {
cir.setReturnValue(Either.right(Unit.INSTANCE));
}
}
@Inject(method = "wakeUpPlayer", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;sleepTimer:I"))
private void arclight$wakeup(boolean immediately, boolean updateWorldFlag, boolean setSpawn, CallbackInfo ci, Optional<BlockPos> optional) {
if (this.bridge$getBukkitEntity() instanceof Player) {
Player player = (Player) this.bridge$getBukkitEntity();
BlockPos blockposition2 = optional.orElse(null);
Block bed;
if (blockposition2 != null) {
bed = CraftBlock.at(this.world, blockposition2);
} else {
bed = ((WorldBridge) this.world).bridge$getWorld().getBlockAt(player.getLocation());
}
PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed, setSpawn);
Bukkit.getPluginManager().callEvent(event);
arclight$setSpawn = event.shouldSetSpawnLocation();
}
}
private boolean arclight$setSpawn;
@ModifyVariable(method = "wakeUpPlayer", index = 3, name = "setSpawn", at = @At(value = "FIELD", shift = At.Shift.AFTER, target = "Lnet/minecraft/entity/player/PlayerEntity;sleepTimer:I"))
private boolean arclight$modifySpawn(boolean setSpawn) {
return arclight$setSpawn;
}
@Inject(method = "setSpawnPoint(Lnet/minecraft/util/math/BlockPos;Z)V", at = @At("RETURN"))
private void arclight$updateSpawnpoint(BlockPos pos, boolean forced, CallbackInfo ci) {
bridge$setSpawnWorld(pos == null ? "" : this.world.worldInfo.getWorldName());
}
@Override
public Either<PlayerEntity.SleepResult, Unit> bridge$trySleep(BlockPos at, boolean force) {
return sleep(at, force);
}
}

View File

@ -1,264 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.entity.player;
import com.mojang.datafixers.util.Either;
import io.izzel.arclight.common.bridge.entity.InternalEntityBridge;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.network.play.ServerPlayNetHandler;
import net.minecraft.network.play.server.SChangeGameStatePacket;
import net.minecraft.network.play.server.SPlayEntityEffectPacket;
import net.minecraft.network.play.server.SPlaySoundEventPacket;
import net.minecraft.network.play.server.SPlayerAbilitiesPacket;
import net.minecraft.network.play.server.SRespawnPacket;
import net.minecraft.network.play.server.SServerDifficultyPacket;
import net.minecraft.potion.EffectInstance;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.management.PlayerInteractionManager;
import net.minecraft.server.management.PlayerList;
import net.minecraft.stats.Stats;
import net.minecraft.util.Unit;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.storage.WorldInfo;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v.CraftWorld;
import org.bukkit.craftbukkit.v.entity.CraftPlayer;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.craftbukkit.v.util.BlockStateListPopulator;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.world.PortalCreateEvent;
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;
import javax.annotation.Nullable;
import java.util.List;
@Mixin(ServerPlayerEntity.class)
public abstract class ServerPlayerEntityMixin_1_14 extends PlayerEntityMixin_1_14 implements ServerPlayerEntityBridge {
// @formatter:off
@Shadow public boolean invulnerableDimensionChange;
@Shadow public abstract ServerWorld func_71121_q();
@Shadow public boolean queuedEndExit;
@Shadow public ServerPlayNetHandler connection;
@Shadow private boolean seenCredits;
@Shadow @Final public MinecraftServer server;
@Shadow @Final public PlayerInteractionManager interactionManager;
@Shadow @Nullable private Vec3d enteredNetherPosition;
@Shadow public abstract void func_213846_b(ServerWorld p_213846_1_);
@Shadow public int lastExperience;
@Shadow private float lastHealth;
@Shadow private int lastFoodLevel;
// @formatter:on
@Override
public CraftPlayer bridge$getBukkitEntity() {
return (CraftPlayer) ((InternalEntityBridge) this).internal$getBukkitEntity();
}
/**
* @author IzzelAliz
* @reason
*/
@Nullable
@Overwrite
public Entity changeDimension(DimensionType dimensionmanager) {
PlayerTeleportEvent.TeleportCause cause = bridge$getTeleportCause().orElse(PlayerTeleportEvent.TeleportCause.UNKNOWN);
if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension((ServerPlayerEntity) (Object) this, dimensionmanager))
return null;
if (this.isSleeping()) {
return (ServerPlayerEntity) (Object) this;
}
DimensionType dimensionmanager2 = this.dimension;
if (((DimensionTypeBridge) dimensionmanager2).bridge$getType() == DimensionType.THE_END && ((DimensionTypeBridge) dimensionmanager).bridge$getType() == DimensionType.OVERWORLD) {
this.invulnerableDimensionChange = true;
this.detach();
this.func_71121_q().removePlayer((ServerPlayerEntity) (Object) this, true);
if (!this.queuedEndExit) {
this.queuedEndExit = true;
this.connection.sendPacket(new SChangeGameStatePacket(4, this.seenCredits ? 0.0f : 1.0f));
this.seenCredits = true;
}
return (ServerPlayerEntity) (Object) this;
}
ServerWorld worldserver = this.server.func_71218_a(dimensionmanager2);
ServerWorld worldserver2 = this.server.func_71218_a(dimensionmanager);
WorldInfo worlddata = this.world.getWorldInfo();
double d0 = this.posX;
double d2 = this.posY;
double d3 = this.posZ;
float f = this.rotationPitch;
float f2 = this.rotationYaw;
double d4 = 8.0;
float f3 = f2;
worldserver.getProfiler().startSection("moving");
if (worldserver2 != null) {
if (dimensionmanager2 == DimensionType.OVERWORLD && dimensionmanager == DimensionType.THE_NETHER) {
this.enteredNetherPosition = new Vec3d(this.posX, this.posY, this.posZ);
d0 /= 8.0;
d3 /= 8.0;
} else if (dimensionmanager2 == DimensionType.THE_NETHER && dimensionmanager == DimensionType.OVERWORLD) {
d0 *= 8.0;
d3 *= 8.0;
} else if (dimensionmanager2 == DimensionType.OVERWORLD && dimensionmanager == DimensionType.THE_END) {
BlockPos blockposition = worldserver2.getSpawnCoordinate();
d0 = blockposition.getX();
d2 = blockposition.getY();
d3 = blockposition.getZ();
f2 = 90.0f;
f = 0.0f;
}
}
Location enter = this.bridge$getBukkitEntity().getLocation();
Location exit = (worldserver2 == null) ? null : new Location(((WorldBridge) worldserver2).bridge$getWorld(), d0, d2, d3, f2, f);
PlayerPortalEvent event = new PlayerPortalEvent((Player) this.bridge$getBukkitEntity(), enter, exit, cause);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled() || event.getTo() == null) {
return null;
}
exit = event.getTo();
if (exit == null) {
return null;
}
PlayerTeleportEvent tpEvent = new PlayerTeleportEvent((Player) this.bridge$getBukkitEntity(), enter, exit, cause);
Bukkit.getServer().getPluginManager().callEvent(tpEvent);
if (tpEvent.isCancelled() || tpEvent.getTo() == null) {
return null;
}
exit = tpEvent.getTo();
if (exit == null) {
return null;
}
worldserver2 = ((CraftWorld) exit.getWorld()).getHandle();
d0 = exit.getX();
d2 = exit.getY();
d3 = exit.getZ();
f2 = exit.getYaw();
f = exit.getPitch();
this.invulnerableDimensionChange = true;
dimensionmanager = worldserver2.getDimension().getType();
this.dimension = dimensionmanager;
net.minecraftforge.fml.network.NetworkHooks.sendDimensionDataPacket(this.connection.netManager, (ServerPlayerEntity) (Object) this);
this.connection.sendPacket(new SRespawnPacket(worldserver2.dimension.getType(), this.world.getWorldInfo().getGenerator(), this.interactionManager.getGameType()));
this.connection.sendPacket(new SServerDifficultyPacket(this.world.getDifficulty(), this.world.getWorldInfo().isDifficultyLocked()));
PlayerList playerlist = this.server.getPlayerList();
playerlist.updatePermissionLevel((ServerPlayerEntity) (Object) this);
worldserver.removePlayer((ServerPlayerEntity) (Object) this, true);
this.removed = false;
this.setLocationAndAngles(d0, d2, d3, f2, f);
worldserver.getProfiler().endSection();
worldserver.getProfiler().startSection("placing");
double d5 = Math.min(-2.9999872E7, worldserver2.getWorldBorder().minX() + 16.0);
double d6 = Math.min(-2.9999872E7, worldserver2.getWorldBorder().minZ() + 16.0);
double d7 = Math.min(2.9999872E7, worldserver2.getWorldBorder().maxX() - 16.0);
double d8 = Math.min(2.9999872E7, worldserver2.getWorldBorder().maxZ() - 16.0);
d0 = MathHelper.clamp(d0, d5, d7);
d3 = MathHelper.clamp(d3, d6, d8);
this.setLocationAndAngles(d0, d2, d3, f2, f);
if (((DimensionTypeBridge) dimensionmanager).bridge$getType() == DimensionType.THE_END) {
int i = MathHelper.floor(this.posX);
int j = MathHelper.floor(this.posY) - 1;
int k = MathHelper.floor(this.posZ);
boolean flag = true;
boolean flag2 = false;
BlockStateListPopulator blockList = new BlockStateListPopulator(worldserver2);
for (int l = -2; l <= 2; ++l) {
for (int i2 = -2; i2 <= 2; ++i2) {
for (int j2 = -1; j2 < 3; ++j2) {
int k2 = i + i2 * 1 + l * 0;
int l2 = j + j2;
int i3 = k + i2 * 0 - l * 1;
boolean flag3 = j2 < 0;
blockList.setBlockState(new BlockPos(k2, l2, i3), flag3 ? Blocks.OBSIDIAN.getDefaultState() : Blocks.AIR.getDefaultState(), 3);
}
}
}
org.bukkit.World bworld = ((WorldBridge) worldserver2).bridge$getWorld();
PortalCreateEvent portalEvent = new PortalCreateEvent((List) blockList.getList(), bworld, this.bridge$getBukkitEntity(), PortalCreateEvent.CreateReason.END_PLATFORM);
Bukkit.getPluginManager().callEvent(portalEvent);
if (!portalEvent.isCancelled()) {
blockList.updateList();
}
this.setLocationAndAngles(i, j, k, f2, 0.0f);
this.setMotion(Vec3d.ZERO);
} else if (!worldserver2.getDefaultTeleporter().placeInPortal((ServerPlayerEntity) (Object) this, f3)) {
worldserver2.getDefaultTeleporter().makePortal((ServerPlayerEntity) (Object) this);
worldserver2.getDefaultTeleporter().placeInPortal((ServerPlayerEntity) (Object) this, f3);
}
worldserver.getProfiler().endSection();
this.setWorld(worldserver2);
worldserver2.func_217447_b((ServerPlayerEntity) (Object) this);
this.func_213846_b(worldserver);
this.connection.setPlayerLocation(this.posX, this.posY, this.posZ, f2, f);
this.interactionManager.func_73080_a(worldserver2);
this.connection.sendPacket(new SPlayerAbilitiesPacket(this.abilities));
playerlist.func_72354_b((ServerPlayerEntity) (Object) this, worldserver2);
playerlist.sendInventory((ServerPlayerEntity) (Object) this);
for (EffectInstance mobeffect : this.getActivePotionEffects()) {
this.connection.sendPacket(new SPlayEntityEffectPacket(this.getEntityId(), mobeffect));
}
this.connection.sendPacket(new SPlaySoundEventPacket(1032, BlockPos.ZERO, 0, false));
this.lastExperience = -1;
this.lastHealth = -1.0f;
this.lastFoodLevel = -1;
PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent((Player) this.bridge$getBukkitEntity(), ((WorldBridge) worldserver).bridge$getWorld());
Bukkit.getPluginManager().callEvent(changeEvent);
net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerChangedDimensionEvent((ServerPlayerEntity) (Object) this, dimensionmanager2, dimensionmanager);
return (ServerPlayerEntity) (Object) this;
}
public Entity a(DimensionType dimensionmanager, final PlayerTeleportEvent.TeleportCause cause) {
bridge$pushChangeDimensionCause(cause);
return this.changeDimension(dimensionmanager);
}
@Override
public Either<PlayerEntity.SleepResult, Unit> sleep(BlockPos at, boolean force) {
return super.sleep(at, force).ifRight((p_213849_1_) -> {
this.addStat(Stats.SLEEP_IN_BED);
CriteriaTriggers.SLEPT_IN_BED.trigger((ServerPlayerEntity) (Object) this);
});
}
@Inject(method = "wakeUpPlayer", cancellable = true, at = @At("HEAD"))
private void arclight$notWake(boolean immediately, boolean updateWorldFlag, boolean setSpawn, CallbackInfo ci) {
if (!isSleeping()) ci.cancel();
}
@Override
public Entity bridge$changeDimension(DimensionType dimensionType, PlayerTeleportEvent.TeleportCause cause) {
return a(dimensionType, cause);
}
@Inject(method = "setElytraFlying", cancellable = true, at = @At("HEAD"))
private void arclight$beginGlide(CallbackInfo ci) {
if (CraftEventFactory.callToggleGlideEvent((ServerPlayerEntity) (Object) this, true).isCancelled()) {
ci.cancel();
}
}
@Inject(method = "clearElytraFlying", cancellable = true, at = @At("HEAD"))
private void arclight$endGlide(CallbackInfo ci) {
if (CraftEventFactory.callToggleGlideEvent((ServerPlayerEntity) (Object) this, false).isCancelled()) {
ci.cancel();
}
}
}

View File

@ -1,18 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.item;
import io.izzel.arclight.common.bridge.item.BlockItemBridge;
import net.minecraft.block.BlockState;
import net.minecraft.item.BlockItem;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(BlockItem.class)
public class BlockItemMixin_1_14 implements BlockItemBridge {
@Override
public boolean bridge$noCollisionInSel(World world, BlockState state, BlockPos pos, ISelectionContext context) {
return world.func_217350_a(state, pos, context);
}
}

View File

@ -1,29 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.network.play;
import io.izzel.arclight.common.bridge.network.play.ServerPlayNetHandlerBridge;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.nbt.StringNBT;
import net.minecraft.network.play.ServerPlayNetHandler;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.server.ServerWorld;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(ServerPlayNetHandler.class)
public abstract class ServerPlayNetHandlerMixin_1_14 implements ServerPlayNetHandlerBridge {
@Override
public boolean bridge$worldNoCollision(ServerWorld world, Entity entity, AxisAlignedBB aabb) {
return world.isCollisionBoxesEmpty(entity, aabb);
}
@Override
public StringNBT bridge$stringNbt(String s) {
return new StringNBT(s);
}
@Override
public void bridge$dropItems(ServerPlayerEntity player, boolean all) {
player.dropItem(all);
}
}

View File

@ -1,128 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.server.management;
import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge;
import io.izzel.arclight.common.bridge.server.management.PlayerInteractionManagerBridge;
import net.minecraft.block.BlockState;
import net.minecraft.block.CakeBlock;
import net.minecraft.block.DoorBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.network.play.client.CPlayerDiggingPacket;
import net.minecraft.network.play.server.SChangeBlockPacket;
import net.minecraft.network.play.server.SPlayerDiggingPacket;
import net.minecraft.server.management.PlayerInteractionManager;
import net.minecraft.state.properties.DoubleBlockHalf;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.GameType;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.ForgeHooks;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.Event;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(PlayerInteractionManager.class)
public abstract class PlayerInteractionManagerMixin_1_14 implements PlayerInteractionManagerBridge {
// @formatter:off
@Shadow public abstract void func_225415_a(BlockPos p_225415_1_, CPlayerDiggingPacket.Action p_225415_2_);
@Shadow private GameType gameType;
@Shadow public ServerWorld world;
@Shadow public abstract boolean isCreative();
// @formatter:on
@Override
public SPlayerDiggingPacket bridge$diggingPacket(BlockPos pos, BlockState state, CPlayerDiggingPacket.Action action, boolean successful, String context) {
return new SPlayerDiggingPacket(pos, state, action, successful);
}
@Override
public void bridge$creativeHarvestBlock(BlockPos pos, CPlayerDiggingPacket.Action action, String context) {
this.func_225415_a(pos, action);
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public ActionResultType func_219441_a(PlayerEntity playerIn, World worldIn, ItemStack stackIn, Hand handIn, BlockRayTraceResult blockRaytraceResultIn) {
BlockPos blockpos = blockRaytraceResultIn.getPos();
BlockState blockstate = worldIn.getBlockState(blockpos);
ActionResultType resultType = ActionResultType.PASS;
boolean cancelledBlock = false;
if (this.gameType == GameType.SPECTATOR) {
INamedContainerProvider provider = blockstate.getContainer(worldIn, blockpos);
cancelledBlock = !(provider instanceof INamedContainerProvider);
}
if (playerIn.getCooldownTracker().hasCooldown(stackIn.getItem())) {
cancelledBlock = true;
}
PlayerInteractEvent bukkitEvent = CraftEventFactory.callPlayerInteractEvent(playerIn, Action.RIGHT_CLICK_BLOCK, blockpos, blockRaytraceResultIn.getFace(), stackIn, cancelledBlock, handIn);
bridge$setFiredInteract(true);
bridge$setInteractResult(bukkitEvent.useItemInHand() == Event.Result.DENY);
if (bukkitEvent.useInteractedBlock() == Event.Result.DENY) {
if (blockstate.getBlock() instanceof DoorBlock) {
boolean bottom = blockstate.get(DoorBlock.HALF) == DoubleBlockHalf.LOWER;
((ServerPlayerEntity) playerIn).connection.sendPacket(new SChangeBlockPacket(this.world, bottom ? blockpos.up() : blockpos.down()));
} else if (blockstate.getBlock() instanceof CakeBlock) {
((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity().sendHealthUpdate();
}
((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity().updateInventory();
resultType = ((bukkitEvent.useItemInHand() != Event.Result.ALLOW) ? ActionResultType.SUCCESS : ActionResultType.PASS);
} else if (this.gameType == GameType.SPECTATOR) {
INamedContainerProvider inamedcontainerprovider = blockstate.getContainer(worldIn, blockpos);
if (inamedcontainerprovider != null) {
playerIn.openContainer(inamedcontainerprovider);
return ActionResultType.SUCCESS;
} else {
return ActionResultType.PASS;
}
} else {
net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock event = ForgeHooks.onRightClickBlock(playerIn, handIn, blockpos, blockRaytraceResultIn.getFace());
if (event.isCanceled()) return event.getCancellationResult();
ItemUseContext itemusecontext = new ItemUseContext(playerIn, handIn, blockRaytraceResultIn);
if (event.getUseItem() != net.minecraftforge.eventbus.api.Event.Result.DENY) {
ActionResultType result = stackIn.onItemUseFirst(itemusecontext);
if (result != ActionResultType.PASS) return result;
}
boolean flag = !playerIn.getHeldItemMainhand().isEmpty() || !playerIn.getHeldItemOffhand().isEmpty();
boolean flag1 = !(playerIn.isSneaking() && flag) || (playerIn.getHeldItemMainhand().doesSneakBypassUse(worldIn, blockpos, playerIn) && playerIn.getHeldItemOffhand().doesSneakBypassUse(worldIn, blockpos, playerIn));
boolean flag2 = blockstate.onBlockActivated(worldIn, playerIn, handIn, blockRaytraceResultIn);
if (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY && flag1 && flag2) {
return ActionResultType.SUCCESS;
} else {
if (flag1) {
resultType = flag2 ? ActionResultType.SUCCESS : ActionResultType.FAIL;
}
if (!stackIn.isEmpty() && resultType != ActionResultType.SUCCESS && !bridge$getInteractResult()) {
if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) {
return ActionResultType.PASS;
}
if (this.isCreative()) {
int i = stackIn.getCount();
resultType = stackIn.onItemUse(itemusecontext);
stackIn.setCount(i);
return resultType;
} else {
return stackIn.onItemUse(itemusecontext);
}
} else {
return resultType;
}
}
}
return resultType;
}
}

View File

@ -1,43 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.server.management;
import io.izzel.arclight.common.bridge.server.management.PlayerListBridge;
import io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge;
import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SJoinGamePacket;
import net.minecraft.network.play.server.SRespawnPacket;
import net.minecraft.server.management.PlayerList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.GameType;
import net.minecraft.world.WorldType;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(PlayerList.class)
public abstract class PlayerListMixin_1_14 implements PlayerListBridge {
@Override
public boolean bridge$worldNoCollision(ServerWorld world, Entity entity) {
return world.areCollisionShapesEmpty(entity);
}
@Override
public void bridge$setSpawnPoint(ServerPlayerEntity player, BlockPos pos, boolean flag, DimensionType type, boolean flag1) {
player.setSpawnPoint(pos, flag, type);
}
@Override
public SRespawnPacket bridge$respawnPacket(DimensionType type, long seed, WorldType worldType, GameType gameType) {
return new SRespawnPacket(type, worldType, gameType);
}
@Redirect(method = "initializeConnectionToPlayer", at = @At(value = "NEW", target = "net/minecraft/network/play/server/SJoinGamePacket"))
private SJoinGamePacket arclight$spawnPacket(int playerId, GameType gameType, boolean hardcoreMode, DimensionType dimensionType, int maxPlayers, WorldType worldType, int viewDistance, boolean reducedDebugInfo, NetworkManager netManager, ServerPlayerEntity playerIn) {
return new SJoinGamePacket(playerId, gameType, hardcoreMode, ((DimensionTypeBridge) dimensionType).bridge$getType(), maxPlayers, worldType, ((ServerWorldBridge) playerIn.func_71121_q()).bridge$spigotConfig().viewDistance, reducedDebugInfo);
}
}

View File

@ -1,136 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.world;
import io.izzel.arclight.common.bridge.world.ExplosionBridge;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootParameters;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.block.BlockIgniteEvent;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.List;
import java.util.Random;
@Mixin(Explosion.class)
public abstract class ExplosionMixin_1_14 implements ExplosionBridge {
// @formatter:off
@Shadow @Final private World world;
@Shadow @Final private Explosion.Mode mode;
@Shadow @Mutable @Final private float size;
@Shadow @Final private List<BlockPos> affectedBlockPositions;
@Shadow @Final private double x;
@Shadow @Final private double y;
@Shadow @Final private double z;
@Shadow @Final private boolean causesFire;
@Shadow @Final private Random random;
@Accessor("exploder") public abstract Entity bridge$getExploder();
@Accessor("size") public abstract float bridge$getSize();
@Accessor("size") public abstract void bridge$setSize(float size);
@Accessor("mode") public abstract Explosion.Mode bridge$getMode();
// @formatter:on
public boolean wasCanceled = false;
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public void doExplosionB(boolean spawnParticles) {
if (world.isRemote) {
this.world.playSound(this.x, this.y, this.z, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, (1.0F + (this.world.rand.nextFloat() - this.world.rand.nextFloat()) * 0.2F) * 0.7F, false);
}
boolean flag = this.mode != Explosion.Mode.NONE;
if (spawnParticles) {
if (!(this.size < 2.0F) && flag) {
this.world.addParticle(ParticleTypes.EXPLOSION_EMITTER, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D);
} else {
this.world.addParticle(ParticleTypes.EXPLOSION, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D);
}
}
if (flag) {
float yield = this.bridge$callBlockExplodeEvent();
if (Float.isNaN(yield)) {
this.wasCanceled = true;
return;
}
for (BlockPos blockpos : this.affectedBlockPositions) {
BlockState blockstate = this.world.getBlockState(blockpos);
Block block = blockstate.getBlock();
if (spawnParticles) {
double d0 = ((float) blockpos.getX() + this.world.rand.nextFloat());
double d1 = ((float) blockpos.getY() + this.world.rand.nextFloat());
double d2 = ((float) blockpos.getZ() + this.world.rand.nextFloat());
double d3 = d0 - this.x;
double d4 = d1 - this.y;
double d5 = d2 - this.z;
double d6 = MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
d3 = d3 / d6;
d4 = d4 / d6;
d5 = d5 / d6;
double d7 = 0.5D / (d6 / (double) this.size + 0.1D);
d7 = d7 * (double) (this.world.rand.nextFloat() * this.world.rand.nextFloat() + 0.3F);
d3 = d3 * d7;
d4 = d4 * d7;
d5 = d5 * d7;
this.world.addParticle(ParticleTypes.POOF, (d0 + this.x) / 2.0D, (d1 + this.y) / 2.0D, (d2 + this.z) / 2.0D, d3, d4, d5);
this.world.addParticle(ParticleTypes.SMOKE, d0, d1, d2, d3, d4, d5);
}
if (!blockstate.isAir(this.world, blockpos)) {
if (this.world instanceof ServerWorld && blockstate.canDropFromExplosion(this.world, blockpos, (Explosion) (Object) this)) {
TileEntity tileentity = blockstate.hasTileEntity() ? this.world.getTileEntity(blockpos) : null;
LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld) this.world)).withRandom(this.world.rand).withParameter(LootParameters.POSITION, blockpos).withParameter(LootParameters.TOOL, ItemStack.EMPTY).withNullableParameter(LootParameters.BLOCK_ENTITY, tileentity);
if (this.mode == Explosion.Mode.DESTROY || yield < 1.0F) {
lootcontext$builder.withParameter(LootParameters.EXPLOSION_RADIUS, 1.0F / yield);
}
Block.spawnDrops(blockstate, lootcontext$builder);
}
blockstate.onBlockExploded(this.world, blockpos, (Explosion) (Object) this);
}
}
}
if (this.causesFire) {
for (BlockPos blockPos : this.affectedBlockPositions) {
if (this.world.getBlockState(blockPos).isAir(world, blockPos) && this.world.getBlockState(blockPos.down()).isOpaqueCube(this.world, blockPos.down()) && this.random.nextInt(3) == 0) {
BlockIgniteEvent event = CraftEventFactory.callBlockIgniteEvent(this.world, blockPos.getX(), blockPos.getY(), blockPos.getZ(), (Explosion) (Object) this);
if (!event.isCancelled()) {
this.world.setBlockState(blockPos, Blocks.FIRE.getDefaultState());
}
}
}
}
}
@Override
public boolean bridge$wasCancelled() {
return wasCanceled;
}
}

View File

@ -1,37 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.world;
import net.minecraft.profiler.IProfiler;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.ServerMultiWorld;
import net.minecraft.world.border.IBorderListener;
import net.minecraft.world.chunk.listener.IChunkStatusListener;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.storage.SaveHandler;
import net.minecraft.world.storage.WorldInfo;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import java.util.concurrent.Executor;
@Mixin(ServerMultiWorld.class)
public abstract class ServerMultiWorldMixin_1_14 extends WorldMixin_1_14 {
// @formatter:off
@Shadow(remap = false) @Final @Mutable private ServerWorld delegate;
@Shadow(remap = false) @Final @Mutable private IBorderListener borderListener;
// @formatter:on
public void arclight$constructor$super(MinecraftServer serverIn, Executor executor, SaveHandler saveHandler, WorldInfo worldInfo, DimensionType dimType, IProfiler profiler, IChunkStatusListener listener, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env) {
throw new RuntimeException();
}
public void arclight$constructor(ServerWorld world, MinecraftServer serverIn, Executor executor, SaveHandler saveHandler, DimensionType dimType, IProfiler profiler, IChunkStatusListener listener, WorldInfo worldInfo, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env) {
arclight$constructor$super(serverIn, executor, saveHandler, worldInfo, dimType, profiler, listener, gen, env);
this.delegate = world;
this.borderListener = new IBorderListener.Impl(this.getWorldBorder());
world.getWorldBorder().addListener(this.borderListener);
}
}

View File

@ -1,72 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.world;
import io.izzel.arclight.common.bridge.entity.EntityBridge;
import io.izzel.arclight.common.bridge.world.TeleporterBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import net.minecraft.block.BlockState;
import net.minecraft.block.pattern.BlockPattern;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Teleporter;
import net.minecraft.world.server.ServerWorld;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.util.BlockStateListPopulator;
import org.bukkit.event.world.PortalCreateEvent;
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;
import java.util.List;
@Mixin(Teleporter.class)
public abstract class TeleporterMixin_1_14 implements TeleporterBridge {
// @formatter:off
@Shadow @Final protected ServerWorld world;
@Shadow public abstract boolean makePortal(Entity entityIn);
// @formatter:on
private transient BlockStateListPopulator arclight$populator;
@Redirect(method = "makePortal", 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$portalPlace1(ServerWorld serverWorld, BlockPos pos, BlockState newState, int flags) {
if (arclight$populator == null) {
arclight$populator = new BlockStateListPopulator(serverWorld);
}
return arclight$populator.setBlockState(pos, newState, flags);
}
@Redirect(method = "makePortal", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z"))
public boolean arclight$portalPlace2(ServerWorld serverWorld, BlockPos pos, BlockState state) {
if (arclight$populator == null) {
arclight$populator = new BlockStateListPopulator(serverWorld);
}
return arclight$populator.setBlockState(pos, state, 3);
}
@Inject(method = "makePortal", at = @At("RETURN"))
@SuppressWarnings({"unchecked", "rawtypes"})
public void arclight$portalCreate(Entity entityIn, CallbackInfoReturnable<Boolean> cir) {
PortalCreateEvent event = new PortalCreateEvent((List) arclight$populator.getList(), ((WorldBridge) this.world).bridge$getWorld(),
((EntityBridge) entityIn).bridge$getBukkitEntity(), PortalCreateEvent.CreateReason.NETHER_PAIR);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
arclight$populator.updateList();
}
arclight$populator = null;
}
@Override
public boolean bridge$makePortal(Entity entityIn, BlockPos pos, int createRadius) {
return this.makePortal(entityIn);
}
@Override
public BlockPattern.PortalInfo bridge$placeInPortal(Entity p_222268_1_, BlockPos pos, float p_222268_2_, int searchRadius, boolean searchOnly) {
throw new IllegalStateException("Not implement");
}
}

View File

@ -1,14 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.world;
import net.minecraft.world.World;
import net.minecraft.world.border.WorldBorder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(World.class)
public abstract class WorldMixin_1_14 {
// @formatter:off
@Shadow public abstract WorldBorder getWorldBorder();
// @formatter:on
}

View File

@ -1,29 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.world.chunk;
import io.izzel.arclight.common.bridge.world.chunk.ChunkBridge;
import net.minecraft.block.Block;
import net.minecraft.fluid.Fluid;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.ITickList;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkSection;
import net.minecraft.world.chunk.UpgradeData;
import org.bukkit.craftbukkit.v.CraftChunk;
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.function.Consumer;
@Mixin(Chunk.class)
public abstract class ChunkMixin_1_14 implements ChunkBridge {
@Inject(method = "<init>(Lnet/minecraft/world/World;Lnet/minecraft/util/math/ChunkPos;[Lnet/minecraft/world/biome/Biome;Lnet/minecraft/world/chunk/UpgradeData;Lnet/minecraft/world/ITickList;Lnet/minecraft/world/ITickList;J[Lnet/minecraft/world/chunk/ChunkSection;Ljava/util/function/Consumer;)V",
at = @At("RETURN"))
private void arclight$init(World worldIn, ChunkPos p_i49946_2_, Biome[] p_i49946_3_, UpgradeData p_i49946_4_, ITickList<Block> p_i49946_5_, ITickList<Fluid> p_i49946_6_, long p_i49946_7_, ChunkSection[] p_i49946_9_, Consumer<Chunk> p_i49946_10_, CallbackInfo ci) {
bridge$setBukkitChunk(new CraftChunk((Chunk) (Object) this));
}
}

View File

@ -1,48 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.world.dimension;
import io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge;
import net.minecraft.world.World;
import net.minecraft.world.dimension.Dimension;
import net.minecraft.world.dimension.DimensionType;
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.function.BiFunction;
@Mixin(DimensionType.class)
public class DimensionTypeMixin_1_14 implements DimensionTypeBridge {
protected void arclight$constructor(int idIn, String suffixIn, String directoryIn, BiFunction<World, DimensionType, ? extends Dimension> p_i49935_4_, boolean p_i49935_5_) {
throw new RuntimeException();
}
public void arclight$constructor(int idIn, String suffixIn, String directoryIn, BiFunction<World, DimensionType, ? extends Dimension> p_i49935_4_, boolean p_i49935_5_, DimensionType type) {
arclight$constructor(idIn, suffixIn, directoryIn, p_i49935_4_, p_i49935_5_);
this.type = type;
}
private DimensionType type;
public DimensionType getType() {
return (type == null) ? (DimensionType) (Object) this : type;
}
@Override
public void bridge$setType(DimensionType type) {
this.type = type;
}
@Override
public DimensionType bridge$getType() {
return getType();
}
@Inject(method = "isVanilla", remap = false, cancellable = true, at = @At("HEAD"))
private void arclight$vanillaCheck(CallbackInfoReturnable<Boolean> cir) {
if (this.type != null) {
cir.setReturnValue(this.type.isVanilla());
}
}
}

View File

@ -1,23 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.world.gen.feature.structure;
import io.izzel.arclight.common.bridge.world.IWorldWriterBridge;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.feature.structure.SwampHutPiece;
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.Random;
@Mixin(SwampHutPiece.class)
public class SwampHutPieceMixin_1_14 {
@Inject(method = "addComponentParts", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/IWorld;addEntity(Lnet/minecraft/entity/Entity;)Z"))
public void arclight$spawnReason(IWorld worldIn, Random randomIn, MutableBoundingBox structureBoundingBoxIn, ChunkPos chunkPosIn, CallbackInfoReturnable<Boolean> cir) {
((IWorldWriterBridge) worldIn).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.CHUNK_GEN);
}
}

View File

@ -1,19 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.world.server;
import io.izzel.arclight.common.bridge.world.server.ServerChunkProviderBridge;
import net.minecraft.entity.EntityClassification;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.server.ServerChunkProvider;
import net.minecraft.world.spawner.WorldEntitySpawner;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(ServerChunkProvider.class)
public abstract class ServerChunkProviderMixin_1_14 implements ServerChunkProviderBridge {
@Override
public void bridge$worldNaturalSpawn(EntityClassification classification, World worldIn, Chunk chunk, BlockPos pos) {
WorldEntitySpawner.performNaturalSpawning(classification, worldIn, chunk, pos);
}
}

View File

@ -1,135 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.world.server;
import io.izzel.arclight.common.bridge.world.server.TicketManagerBridge;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectBidirectionalIterator;
import it.unimi.dsi.fastutil.objects.ObjectSortedSet;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.server.ChunkManager;
import net.minecraft.world.server.Ticket;
import net.minecraft.world.server.TicketManager;
import net.minecraft.world.server.TicketType;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.gen.Invoker;
import java.util.Iterator;
@Mixin(TicketManager.class)
public abstract class TicketManagerMixin_1_14 implements TicketManagerBridge {
// @formatter:off
@Shadow @Final public Long2ObjectOpenHashMap<ObjectSortedSet<Ticket<?>>> tickets;
@Shadow private long currentTime;
@Shadow protected abstract ObjectSortedSet<Ticket<?>> getTickets(long chunkPosIn);
@Shadow @Final private TicketManager.ChunkTicketTracker ticketTracker;
@Shadow protected abstract int getChunkLevel(ObjectSortedSet<Ticket<?>> ticketsIn);
@Invoker("tick") public abstract void bridge$tick();
// @formatter:on
@SuppressWarnings("unused") // mock
public <T> boolean func_219356_a(TicketType<T> type, ChunkPos pos, int level, T value) {
return addTicketAtLevel(type, pos, level, value);
}
@SuppressWarnings("unused") // mock
public <T> boolean func_219345_b(TicketType<T> type, ChunkPos pos, int level, T value) {
return removeTicketAtLevel(type, pos, level, value);
}
public <T> boolean addTicketAtLevel(TicketType<T> type, ChunkPos pos, int level, T value) {
Ticket<T> ticket = new Ticket<>(type, level, value, this.currentTime);
return this.addTicket(pos.asLong(), ticket);
}
public <T> boolean removeTicketAtLevel(TicketType<T> type, ChunkPos pos, int level, T value) {
Ticket<T> ticket = new Ticket<>(type, level, value, this.currentTime);
return this.removeTicket(pos.asLong(), ticket);
}
@Override
public <T> boolean bridge$addTicketAtLevel(TicketType<T> type, ChunkPos pos, int level, T value) {
return addTicketAtLevel(type, pos, level, value);
}
@Override
public <T> boolean bridge$removeTicketAtLevel(TicketType<T> type, ChunkPos pos, int level, T value) {
return removeTicketAtLevel(type, pos, level, value);
}
@SuppressWarnings("unused") // mock
private boolean func_219349_b(long chunkPosIn, Ticket<?> ticketIn) {
return removeTicket(chunkPosIn, ticketIn);
}
private boolean removeTicket(long chunkPosIn, Ticket<?> ticketIn) {
ObjectSortedSet<Ticket<?>> objectsortedset = this.getTickets(chunkPosIn);
boolean ret = false;
if (objectsortedset.remove(ticketIn)) {
ret = true;
}
if (objectsortedset.isEmpty()) {
this.tickets.remove(chunkPosIn);
}
this.ticketTracker.updateSourceLevel(chunkPosIn, this.getChunkLevel(objectsortedset), false);
return ret;
}
@Override
public boolean bridge$removeTicket(long chunkPos, Ticket<?> ticket) {
return removeTicket(chunkPos, ticket);
}
@SuppressWarnings("unused") // mock
private boolean func_219347_a(long chunkPosIn, Ticket<?> ticketIn) {
return addTicket(chunkPosIn, ticketIn);
}
private boolean addTicket(long chunkPosIn, Ticket<?> ticketIn) {
ObjectSortedSet<Ticket<?>> objectsortedset = this.getTickets(chunkPosIn);
ObjectBidirectionalIterator<Ticket<?>> objectbidirectionaliterator = objectsortedset.iterator();
int i;
if (objectbidirectionaliterator.hasNext()) {
i = objectbidirectionaliterator.next().getLevel();
} else {
i = ChunkManager.MAX_LOADED_LEVEL + 1;
}
boolean ret = false;
if (objectsortedset.add(ticketIn)) {
ret = true;
}
if (ticketIn.getLevel() < i) {
this.ticketTracker.updateSourceLevel(chunkPosIn, ticketIn.getLevel(), true);
}
return ret;
}
@Override
public boolean bridge$addTicket(long chunkPos, Ticket<?> ticket) {
return addTicket(chunkPos, ticket);
}
public <T> void removeAllTicketsFor(TicketType<T> ticketType, int ticketLevel, T ticketIdentifier) {
Ticket<T> target = new Ticket<>(ticketType, ticketLevel, ticketIdentifier, this.currentTime);
for (Iterator<ObjectSortedSet<Ticket<?>>> iterator = this.tickets.values().iterator(); iterator.hasNext(); ) {
ObjectSortedSet<Ticket<?>> tickets = iterator.next();
tickets.remove(target);
if (tickets.isEmpty()) {
iterator.remove();
}
}
}
@Override
public <T> void bridge$removeAllTicketsFor(TicketType<T> ticketType, int ticketLevel, T ticketIdentifier) {
removeAllTicketsFor(ticketType, ticketLevel, ticketIdentifier);
}
}

View File

@ -1,32 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.world.spawner;
import io.izzel.arclight.common.bridge.world.IWorldWriterBridge;
import io.izzel.arclight.common.bridge.world.WorldBridge;
import net.minecraft.entity.EntityClassification;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.spawner.WorldEntitySpawner;
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.CallbackInfo;
import java.util.Random;
@Mixin(WorldEntitySpawner.class)
public class WorldEntitySpawnerMixin_1_14 {
@Inject(method = "performNaturalSpawning", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private static void arclight$naturalSpawn(EntityClassification p_222263_0_, World worldIn, Chunk p_222263_2_, BlockPos p_222263_3_, CallbackInfo ci) {
((WorldBridge) worldIn).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.NATURAL);
}
@Inject(method = "performWorldGenSpawning", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/IWorld;addEntity(Lnet/minecraft/entity/Entity;)Z"))
private static void arclight$worldGenSpawn(IWorld worldIn, Biome biomeIn, int centerX, int centerZ, Random diameterX, CallbackInfo ci) {
((IWorldWriterBridge) worldIn).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.CHUNK_GEN);
}
}

View File

@ -1,19 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.core.world.storage;
import io.izzel.arclight.common.bridge.world.storage.MapDataBridge;
import net.minecraft.world.World;
import net.minecraft.world.dimension.Dimension;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.storage.MapData;
import org.spongepowered.asm.mixin.Mixin;
import java.util.function.BiFunction;
@Mixin(MapData.class)
public abstract class MapDataMixin_1_14 implements MapDataBridge {
@Override
public DimensionType bridge$dimension(int id, String suffix, String dir, BiFunction<World, DimensionType, ? extends Dimension> provider, boolean skyLight) {
return new DimensionType(id, suffix, dir, provider, skyLight, null, null);
}
}

View File

@ -1,102 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.optimization;
import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
import it.unimi.dsi.fastutil.doubles.DoubleList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import net.minecraft.util.math.shapes.IDoubleListMerger;
import net.minecraft.util.math.shapes.IndirectMerger;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(IndirectMerger.class)
public class IndirectMergerMixin {
private static final IntArrayList INFINITE_B_1 = new IntArrayList(new int[]{1, 1});
private static final IntArrayList INFINITE_B_0 = new IntArrayList(new int[]{0, 0});
private static final IntArrayList INFINITE_C = new IntArrayList(new int[]{0, 1});
@Shadow @Final @Mutable private IntArrayList list1;
@Shadow @Final @Mutable private IntArrayList list2;
private DoubleList list;
public void arclight$constructor$override(DoubleList list1In, DoubleList list2In, boolean p_i47685_3_, boolean p_i47685_4_) {
int i = 0;
int j = 0;
double d0 = Double.NaN;
int k = list1In.size();
int l = list2In.size();
int i1 = k + l;
int size = list1In.size();
double tail = list1In.getDouble(size - 1);
double head = list1In.getDouble(0);
if (head == Double.NEGATIVE_INFINITY && tail == Double.POSITIVE_INFINITY && !p_i47685_3_ && !p_i47685_4_ && (size == 2 || size == 4)) {
this.list = list2In;
if (size == 2) {
this.list1 = INFINITE_B_0;
} else {
this.list1 = INFINITE_B_1;
}
this.list2 = INFINITE_C;
return;
}
this.list = new DoubleArrayList(i1);
this.list1 = new IntArrayList(i1);
this.list2 = new IntArrayList(i1);
while (true) {
boolean flag = i < k;
boolean flag1 = j < l;
if (!flag && !flag1) {
if (this.list.isEmpty()) {
this.list.add(Math.min(list1In.getDouble(k - 1), list2In.getDouble(l - 1)));
}
return;
}
boolean flag2 = flag && (!flag1 || list1In.getDouble(i) < list2In.getDouble(j) + 1.0E-7D);
double d1 = flag2 ? list1In.getDouble(i++) : list2In.getDouble(j++);
if ((i != 0 && flag || flag2 || p_i47685_4_) && (j != 0 && flag1 || !flag2 || p_i47685_3_)) {
if (!(d0 >= d1 - 1.0E-7D)) {
this.list1.add(i - 1);
this.list2.add(j - 1);
this.list.add(d1);
d0 = d1;
} else if (!this.list.isEmpty()) {
this.list1.set(this.list1.size() - 1, i - 1);
this.list2.set(this.list2.size() - 1, j - 1);
}
}
}
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public boolean forMergedIndexes(IDoubleListMerger.IConsumer consumer) {
for (int i = 0; i < this.list.size() - 1; ++i) {
if (!consumer.merge(this.list1.getInt(i), this.list2.getInt(i), i)) {
return false;
}
}
return true;
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public DoubleList func_212435_a() {
return this.list;
}
}

View File

@ -1,61 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.optimization;
import com.google.common.annotations.VisibleForTesting;
import it.unimi.dsi.fastutil.doubles.DoubleList;
import net.minecraft.util.math.shapes.DoubleCubeMergingList;
import net.minecraft.util.math.shapes.DoubleRangeList;
import net.minecraft.util.math.shapes.IDoubleListMerger;
import net.minecraft.util.math.shapes.IndirectMerger;
import net.minecraft.util.math.shapes.NonOverlappingMerger;
import net.minecraft.util.math.shapes.SimpleDoubleMerger;
import net.minecraft.util.math.shapes.VoxelShapes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import java.util.Objects;
@Mixin(VoxelShapes.class)
public abstract class VoxelShapesMixin {
// @formatter:off
@Shadow protected static long lcm(int aa, int bb) { return 0; }
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@VisibleForTesting
@Overwrite
protected static IDoubleListMerger makeListMerger(final int i, final DoubleList doublelist, final DoubleList doublelist1, final boolean flag, final boolean flag1) {
if (doublelist.getDouble(0) == Double.NEGATIVE_INFINITY && doublelist.getDouble(doublelist.size() - 1) == Double.POSITIVE_INFINITY) {
return new IndirectMerger(doublelist, doublelist1, flag, flag1);
}
int j = doublelist.size() - 1;
int k = doublelist1.size() - 1;
if (doublelist instanceof DoubleRangeList && doublelist1 instanceof DoubleRangeList) {
long l = lcm(j, k);
if (i * l <= 256L) {
return new DoubleCubeMergingList(j, k);
}
}
if (j == k && Objects.equals(doublelist, doublelist1)) {
if (doublelist instanceof SimpleDoubleMerger) {
return (SimpleDoubleMerger) doublelist;
}
if (doublelist1 instanceof SimpleDoubleMerger) {
return (SimpleDoubleMerger) doublelist1;
}
return new SimpleDoubleMerger(doublelist);
} else {
if (doublelist.getDouble(j) < doublelist1.getDouble(0) - 1.0E-7) {
return new NonOverlappingMerger(doublelist, doublelist1, false);
}
if (doublelist1.getDouble(k) < doublelist.getDouble(0) - 1.0E-7) {
return new NonOverlappingMerger(doublelist1, doublelist, true);
}
return new IndirectMerger(doublelist, doublelist1, flag, flag1);
}
}
}

View File

@ -1,119 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.optimization.stream;
import net.minecraft.entity.ai.goal.Goal;
import net.minecraft.entity.ai.goal.GoalSelector;
import net.minecraft.entity.ai.goal.PrioritizedGoal;
import net.minecraft.profiler.IProfiler;
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.EnumSet;
import java.util.Map;
import java.util.Set;
@Mixin(GoalSelector.class)
public abstract class GoalSelectorMixin {
// @formatter:off
@Shadow @Final private IProfiler profiler;
@Shadow @Final private EnumSet<Goal.Flag> disabledFlags;
@Shadow @Final private Map<Goal.Flag, PrioritizedGoal> flagGoals;
@Shadow @Final private Set<PrioritizedGoal> goals;
@Shadow @Final private static PrioritizedGoal DUMMY;
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public void removeGoal(Goal task) {
for (PrioritizedGoal goal : this.goals) {
if (goal.getGoal() == task) {
if (goal.isRunning()) {
goal.resetTask();
}
}
}
this.goals.removeIf((goal) -> goal.getGoal() == task);
}
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public void tick() {
this.profiler.startSection("goalCleanup");
for (PrioritizedGoal prioritizedGoal : this.goals) {
if (prioritizedGoal.isRunning()) {
if (!prioritizedGoal.isRunning()) {
prioritizedGoal.resetTask();
} else {
EnumSet<Goal.Flag> flags = this.disabledFlags;
boolean b = false;
for (Goal.Flag flag : prioritizedGoal.getMutexFlags()) {
if (flags.contains(flag)) {
b = true;
break;
}
}
if (b || !prioritizedGoal.shouldContinueExecuting()) {
prioritizedGoal.resetTask();
}
}
}
}
for (Map.Entry<Goal.Flag, PrioritizedGoal> entry : this.flagGoals.entrySet()) {
Goal.Flag flag = entry.getKey();
PrioritizedGoal prioritizedGoal = entry.getValue();
if (!prioritizedGoal.isRunning()) {
this.flagGoals.remove(flag);
}
}
this.profiler.endSection();
this.profiler.startSection("goalUpdate");
for (PrioritizedGoal prioritizedGoal : this.goals) {
if (!prioritizedGoal.isRunning()) {
EnumSet<Goal.Flag> flags = this.disabledFlags;
boolean b = true;
for (Goal.Flag flag : prioritizedGoal.getMutexFlags()) {
if (flags.contains(flag)) {
b = false;
break;
}
}
if (b) {
boolean result = true;
for (Goal.Flag flag : prioritizedGoal.getMutexFlags()) {
if (!this.flagGoals.getOrDefault(flag, DUMMY).isPreemptedBy(prioritizedGoal)) {
result = false;
break;
}
}
if (result) {
if (prioritizedGoal.shouldExecute()) {
for (Goal.Flag flag : prioritizedGoal.getMutexFlags()) {
PrioritizedGoal prioritizedgoal = this.flagGoals.getOrDefault(flag, DUMMY);
prioritizedgoal.resetTask();
this.flagGoals.put(flag, prioritizedGoal);
}
prioritizedGoal.startExecuting();
}
}
}
}
}
this.profiler.endSection();
this.profiler.startSection("goalTick");
for (PrioritizedGoal goal : this.goals) {
if (goal.isRunning()) {
goal.tick();
}
}
this.profiler.endSection();
}
}

View File

@ -1,35 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.optimization.stream;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IWorldReader;
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.Iterator;
import java.util.Set;
import java.util.stream.Stream;
@Mixin(IWorldReader.class)
public interface IWorldReaderMixin {
// @formatter:off
@Shadow Stream<VoxelShape> getCollisionShapes(@Nullable Entity entityIn, AxisAlignedBB aabb, Set<Entity> entitiesToIgnore);
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
default boolean isCollisionBoxesEmpty(@Nullable Entity entityIn, AxisAlignedBB aabb, Set<Entity> entitiesToIgnore) {
Iterator<VoxelShape> iterator = this.getCollisionShapes(entityIn, aabb, entitiesToIgnore).iterator();
while (iterator.hasNext()) {
if (!iterator.next().isEmpty()) return false;
}
return true;
}
}

View File

@ -1,126 +0,0 @@
package io.izzel.arclight.impl.mixin.v1_14.optimization.stream;
import net.minecraft.pathfinding.FlaggedPathPoint;
import net.minecraft.pathfinding.NodeProcessor;
import net.minecraft.pathfinding.Path;
import net.minecraft.pathfinding.PathFinder;
import net.minecraft.pathfinding.PathHeap;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.math.BlockPos;
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.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@Mixin(PathFinder.class)
public abstract class PathFinderMixin {
// @formatter:off
@Shadow protected abstract float func_224776_a(PathPoint p_224776_1_, Set<FlaggedPathPoint> p_224776_2_);
@Shadow @Final private PathHeap path;
@Shadow @Final private Set<PathPoint> closedSet;
@Shadow @Final private int field_215751_d;
@Shadow @Final private NodeProcessor nodeProcessor;
@Shadow @Final private PathPoint[] pathOptions;
@Shadow protected abstract Path func_224780_a(PathPoint p_224780_1_, BlockPos p_224780_2_, boolean p_224780_3_);
// @formatter:on
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
@Nullable
private Path func_224779_a(PathPoint p_224779_1_, Map<FlaggedPathPoint, BlockPos> p_224779_2_, float p_224779_3_, int p_224779_4_) {
Set<FlaggedPathPoint> set = p_224779_2_.keySet();
p_224779_1_.totalPathDistance = 0.0F;
p_224779_1_.distanceToNext = this.func_224776_a(p_224779_1_, set);
p_224779_1_.distanceToTarget = p_224779_1_.distanceToNext;
this.path.clearPath();
this.closedSet.clear();
this.path.addPoint(p_224779_1_);
int i = 0;
while (!this.path.isPathEmpty()) {
++i;
if (i >= this.field_215751_d) {
break;
}
PathPoint pathpoint = this.path.dequeue();
pathpoint.visited = true;
for (FlaggedPathPoint p_224781_2_ : set) {
if (pathpoint.func_224757_c(p_224781_2_) <= (float) p_224779_4_) {
p_224781_2_.func_224764_e();
}
}
boolean b = false;
for (FlaggedPathPoint flaggedPathPoint : set) {
if (flaggedPathPoint.func_224762_f()) {
b = true;
break;
}
}
if (b) {
break;
}
if (!(pathpoint.distanceTo(p_224779_1_) >= p_224779_3_)) {
int j = this.nodeProcessor.func_222859_a(this.pathOptions, pathpoint);
for (int k = 0; k < j; ++k) {
PathPoint pathpoint1 = this.pathOptions[k];
float f = pathpoint.distanceTo(pathpoint1);
pathpoint1.field_222861_j = pathpoint.field_222861_j + f;
float f1 = pathpoint.totalPathDistance + f + pathpoint1.costMalus;
if (pathpoint1.field_222861_j < p_224779_3_ && (!pathpoint1.isAssigned() || f1 < pathpoint1.totalPathDistance)) {
pathpoint1.previous = pathpoint;
pathpoint1.totalPathDistance = f1;
pathpoint1.distanceToNext = this.func_224776_a(pathpoint1, set) * 1.5F;
if (pathpoint1.isAssigned()) {
this.path.changeDistance(pathpoint1, pathpoint1.totalPathDistance + pathpoint1.distanceToNext);
} else {
pathpoint1.distanceToTarget = pathpoint1.totalPathDistance + pathpoint1.distanceToNext;
this.path.addPoint(pathpoint1);
}
}
}
}
}
List<Path> candidates = new ArrayList<>();
boolean b = false;
for (FlaggedPathPoint flaggedPathPoint : set) {
if (flaggedPathPoint.func_224762_f()) {
b = true;
break;
}
}
if (b) {
for (FlaggedPathPoint point : set) {
if (point.func_224762_f()) {
Path path = this.func_224780_a(point.func_224763_d(), p_224779_2_.get(point), true);
candidates.add(path);
}
}
if (candidates.isEmpty()) return null;
candidates.sort(Comparator.comparingInt(Path::getCurrentPathLength));
} else {
for (FlaggedPathPoint point : set) {
Path path = this.func_224780_a(point.func_224763_d(), p_224779_2_.get(point), false);
candidates.add(path);
}
if (candidates.isEmpty()) return null;
candidates.sort(Comparator.comparingDouble(Path::func_224769_l).thenComparingInt(Path::getCurrentPathLength));
}
return candidates.get(0);
}
}

View File

@ -1,18 +0,0 @@
package io.izzel.arclight.server;
import io.izzel.arclight.api.ArclightVersion;
import io.izzel.arclight.common.ArclightMain;
import io.izzel.arclight.forgeinstaller.ForgeInstaller;
public class Main_1_14 extends ArclightMain {
public static void main(String[] args) throws Throwable {
new Main_1_14().run(args);
}
@Override
protected void afterSetup() throws Throwable {
ArclightVersion.setVersion(ArclightVersion.v1_14);
ForgeInstaller.install();
}
}

View File

@ -1,12 +0,0 @@
modLoader="javafml"
loaderVersion="[24,]"
[[mods]]
modId="arclight"
version="${version}"
displayName="Arclight Mod"
credits="IzzelAliz,lona"
authors="IzzelAliz,lona"
description='''
Arclight bukkit layer for MinecraftForge
'''

View File

@ -1 +0,0 @@
io.izzel.arclight.impl.ArclightLocator_1_14

View File

@ -1,88 +0,0 @@
{
"required": true,
"minVersion": "0.8",
"package": "io.izzel.arclight.impl.mixin.v1_14.core",
"target": "@env(DEFAULT)",
"refmap": "mixins.arclight.impl.refmap.1_14.json",
"setSourceFile": true,
"plugin": "io.izzel.arclight.common.mod.ArclightMixinPlugin",
"injectors": {
"maxShiftBy": 2,
"defaultRequire": 1
},
"mixins": [
"block.AbstractButtonBlockMixin_1_14",
"block.BlockMixin_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.LilyPadBlockMixin_1_14",
"block.MushroomBlockMixin_1_14",
"block.NetherPortalBlockMixin_1_14",
"block.NetherWartBlockMixin_1_14",
"block.NoteBlockMixin_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",
"command.impl.TeleportCommandMixin_1_14",
"enchantment.FrostWalkerEnchantmentMixin_1_14",
"entity.EntityMixin_1_14",
"entity.LivingEntityMixin_1_14",
"entity.MobEntityMixin_1_14",
"entity.ai.goal.FollowOwnerGoalMixin_1_14",
"entity.boss.WitherEntityMixin_1_14",
"entity.item.ArmorStandEntityMixin_1_14",
"entity.item.FallingBlockEntityMixin_1_14",
"entity.item.ItemEntityMixin_1_14",
"entity.item.LeadItemMixin_1_14",
"entity.monster.EndermanEntityMixin_1_14",
"entity.monster.PillagerEntityMixin_1_14",
"entity.monster.RavagerEntityMixin_1_14",
"entity.monster.ShulkerEntityMixin_1_14",
"entity.monster.ZombieEntityMixin_1_14",
"entity.monster.ZombiePigmanEntityMixin_1_14",
"entity.passive.OcelotEntityMixin_1_14",
"entity.passive.PandaEntity_MateGoalMixin",
"entity.player.PlayerEntityMixin_1_14",
"entity.player.ServerPlayerEntityMixin_1_14",
"item.BlockItemMixin_1_14",
"network.play.ServerPlayNetHandlerMixin_1_14",
"server.management.PlayerInteractionManagerMixin_1_14",
"server.management.PlayerListMixin_1_14",
"world.ExplosionMixin_1_14",
"world.ServerMultiWorldMixin_1_14",
"world.TeleporterMixin_1_14",
"world.WorldMixin_1_14",
"world.chunk.ChunkMixin_1_14",
"world.dimension.DimensionTypeMixin_1_14",
"world.gen.feature.structure.SwampHutPieceMixin_1_14",
"world.server.ServerChunkProviderMixin_1_14",
"world.server.TicketManagerMixin_1_14",
"world.spawner.WorldEntitySpawnerMixin_1_14",
"world.storage.MapDataMixin_1_14"
]
}

View File

@ -1,11 +0,0 @@
{
"minVersion": "0.8",
"package": "io.izzel.arclight.impl.mixin.v1_14.optimization",
"target": "@env(DEFAULT)",
"refmap": "mixins.arclight.impl.refmap.1_14.json",
"plugin": "io.izzel.arclight.common.mod.ArclightMixinPlugin",
"mixins": [
"IndirectMergerMixin",
"VoxelShapesMixin"
]
}

View File

@ -1,11 +0,0 @@
{
"minVersion": "0.8",
"package": "io.izzel.arclight.impl.mixin.v1_14.optimization.stream",
"target": "@env(DEFAULT)",
"refmap": "mixins.arclight.impl.refmap.1_14.json",
"mixins": [
"GoalSelectorMixin",
"IWorldReaderMixin",
"PathFinderMixin"
]
}

View File

@ -1,6 +0,0 @@
{
"pack": {
"description": "Arclight resources",
"pack_format": 4
}
}

View File

@ -3,7 +3,7 @@ import java.nio.file.attribute.BasicFileAttributes
allprojects {
group 'io.izzel.arclight'
version '1.0.6'
version '1.0.7-SNAPSHOT'
ext {
agpVersion = '1.8'

View File

@ -1,5 +1,4 @@
rootProject.name = 'arclight'
include 'arclight-forge-1.14'
include 'arclight-common'
include 'forge-installer'
include 'arclight-api'