-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: 秋雨落 <[email protected]>
- Loading branch information
Showing
5 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
...rc/main/java/io/izzel/arclight/common/mixin/bukkit/util/BlockStateListPopulatorMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.izzel.arclight.common.mixin.bukkit.util; | ||
|
||
import io.izzel.arclight.common.bridge.core.world.IWorldWriterBridge; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.level.LevelAccessor; | ||
import org.bukkit.craftbukkit.v.util.BlockStateListPopulator; | ||
import org.bukkit.event.entity.CreatureSpawnEvent; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
@Mixin(BlockStateListPopulator.class) | ||
public class BlockStateListPopulatorMixin implements IWorldWriterBridge { | ||
@Shadow @Final private LevelAccessor world; | ||
|
||
@Override | ||
public boolean bridge$addEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) { | ||
return ((IWorldWriterBridge) world).bridge$addEntity(entity, reason); | ||
} | ||
|
||
@Override | ||
public void bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason reason) { | ||
((IWorldWriterBridge) world).bridge$pushAddEntityReason(reason); | ||
} | ||
|
||
@Override | ||
public CreatureSpawnEvent.SpawnReason bridge$getAddEntityReason() { | ||
return ((IWorldWriterBridge) world).bridge$getAddEntityReason(); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...c/main/java/io/izzel/arclight/common/mixin/bukkit/util/DelegatedGeneratorAccessMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.izzel.arclight.common.mixin.bukkit.util; | ||
|
||
import io.izzel.arclight.common.bridge.core.world.IWorldWriterBridge; | ||
import io.izzel.arclight.common.bridge.core.world.WorldBridge; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.level.WorldGenLevel; | ||
import org.bukkit.craftbukkit.v.util.DelegatedGeneratorAccess; | ||
import org.bukkit.event.entity.CreatureSpawnEvent; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
@Mixin(DelegatedGeneratorAccess.class) | ||
public abstract class DelegatedGeneratorAccessMixin implements IWorldWriterBridge { | ||
@Shadow public abstract WorldGenLevel getHandle(); | ||
|
||
@Override | ||
public boolean bridge$addEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) { | ||
if (getHandle() != (Object) this) { | ||
return ((IWorldWriterBridge) getHandle()).bridge$addEntity(entity, reason); | ||
} else { | ||
this.bridge$pushAddEntityReason(reason); | ||
return getHandle().addFreshEntity(entity); | ||
} | ||
} | ||
|
||
@Override | ||
public void bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason reason) { | ||
if (getHandle() != (Object) this) { | ||
((IWorldWriterBridge) getHandle()).bridge$pushAddEntityReason(reason); | ||
} | ||
} | ||
|
||
@Override | ||
public CreatureSpawnEvent.SpawnReason bridge$getAddEntityReason() { | ||
if (getHandle() != (Object) this) { | ||
return ((IWorldWriterBridge) getHandle()).bridge$getAddEntityReason(); | ||
} | ||
return null; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...n/src/main/java/io/izzel/arclight/common/mixin/bukkit/util/DummyGeneratorAccessMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.izzel.arclight.common.mixin.bukkit.util; | ||
|
||
import io.izzel.arclight.common.bridge.core.world.IWorldWriterBridge; | ||
import net.minecraft.world.entity.Entity; | ||
import org.bukkit.craftbukkit.v.util.DummyGeneratorAccess; | ||
import org.bukkit.event.entity.CreatureSpawnEvent; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
|
||
@Mixin(DummyGeneratorAccess.class) | ||
public class DummyGeneratorAccessMixin implements IWorldWriterBridge { | ||
@Override | ||
public boolean bridge$addEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) { | ||
throw new UnsupportedOperationException("Not supported yet."); | ||
} | ||
|
||
@Override | ||
public void bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason reason) { | ||
throw new UnsupportedOperationException("Not supported yet."); | ||
} | ||
|
||
@Override | ||
public CreatureSpawnEvent.SpawnReason bridge$getAddEntityReason() { | ||
throw new UnsupportedOperationException("Not supported yet."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters