Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dba7af5
commit 46a5bc7
Showing
9 changed files
with
231 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
CraftTweaker2-API/src/main/java/crafttweaker/api/event/ExplosionDetonateEvent.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,23 @@ | ||
package crafttweaker.api.event; | ||
|
||
import crafttweaker.annotations.ZenRegister; | ||
import crafttweaker.api.entity.IEntity; | ||
import crafttweaker.api.world.IBlockPos; | ||
import stanhebben.zenscript.annotations.ZenClass; | ||
import stanhebben.zenscript.annotations.ZenGetter; | ||
import stanhebben.zenscript.annotations.ZenMethod; | ||
|
||
/** | ||
* @author Noob | ||
*/ | ||
@ZenClass("crafttweaker.event.ExplosionDetonateEvent") | ||
@ZenRegister | ||
public interface ExplosionDetonateEvent extends IExplosionEvent { | ||
@ZenGetter("affectedEntities") | ||
@ZenMethod | ||
IEntity[] getAffectedEntities(); | ||
|
||
@ZenGetter("affectedPositions") | ||
@ZenMethod | ||
IBlockPos[] getAffectedPositions(); | ||
} |
17 changes: 17 additions & 0 deletions
17
CraftTweaker2-API/src/main/java/crafttweaker/api/event/ExplosionStartEvent.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,17 @@ | ||
package crafttweaker.api.event; | ||
|
||
import crafttweaker.annotations.ZenRegister; | ||
import crafttweaker.api.entity.IEntity; | ||
import crafttweaker.api.world.IBlockPos; | ||
import crafttweaker.api.world.IWorld; | ||
import stanhebben.zenscript.annotations.ZenClass; | ||
import stanhebben.zenscript.annotations.ZenGetter; | ||
import stanhebben.zenscript.annotations.ZenMethod; | ||
|
||
/** | ||
* @author Noob | ||
*/ | ||
@ZenClass("crafttweaker.event.ExplosionStartEvent") | ||
@ZenRegister | ||
public interface ExplosionStartEvent extends IExplosionEvent { | ||
} |
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
29 changes: 29 additions & 0 deletions
29
CraftTweaker2-API/src/main/java/crafttweaker/api/event/IExplosionEvent.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,29 @@ | ||
package crafttweaker.api.event; | ||
|
||
import crafttweaker.annotations.ZenRegister; | ||
import crafttweaker.api.world.IBlockPos; | ||
import crafttweaker.api.world.IWorld; | ||
import stanhebben.zenscript.annotations.ZenClass; | ||
import stanhebben.zenscript.annotations.ZenGetter; | ||
|
||
/** | ||
* @author Noob | ||
*/ | ||
@ZenClass("crafttweaker.event.IExplosionEvent") | ||
@ZenRegister | ||
public interface IExplosionEvent extends IEventCancelable { | ||
@ZenGetter("world") | ||
IWorld getWorld(); | ||
|
||
@ZenGetter("position") | ||
IBlockPos getPosition(); | ||
|
||
@ZenGetter("x") | ||
double getX(); | ||
|
||
@ZenGetter("y") | ||
double getY(); | ||
|
||
@ZenGetter("z") | ||
double getZ(); | ||
} |
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
34 changes: 34 additions & 0 deletions
34
...1120-Main/src/main/java/crafttweaker/mc1120/events/handling/MCExplosionDetonateEvent.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,34 @@ | ||
package crafttweaker.mc1120.events.handling; | ||
|
||
import crafttweaker.api.entity.IEntity; | ||
import crafttweaker.api.event.ExplosionDetonateEvent; | ||
import crafttweaker.api.minecraft.CraftTweakerMC; | ||
import crafttweaker.api.world.IBlockPos; | ||
import net.minecraftforge.event.world.ExplosionEvent; | ||
|
||
public class MCExplosionDetonateEvent extends MCExplosionEvent implements ExplosionDetonateEvent { | ||
private ExplosionEvent.Detonate event; | ||
private IEntity[] entities = null; | ||
private IBlockPos[] blocks = null; | ||
|
||
public MCExplosionDetonateEvent(ExplosionEvent.Detonate event) { | ||
super(event); | ||
this.event = event; | ||
} | ||
|
||
@Override | ||
public IEntity[] getAffectedEntities() { | ||
if (entities == null) { | ||
entities = event.getAffectedEntities().stream().map(CraftTweakerMC::getIEntity).toArray(IEntity[]::new); | ||
} | ||
return entities; | ||
} | ||
|
||
@Override | ||
public IBlockPos[] getAffectedPositions() { | ||
if (blocks == null) { | ||
blocks = event.getAffectedBlocks().stream().map(CraftTweakerMC::getIBlockPos).toArray(IBlockPos[]::new); | ||
} | ||
return blocks; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...aker2-MC1120-Main/src/main/java/crafttweaker/mc1120/events/handling/MCExplosionEvent.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,56 @@ | ||
package crafttweaker.mc1120.events.handling; | ||
|
||
import crafttweaker.api.event.IExplosionEvent; | ||
import crafttweaker.api.minecraft.CraftTweakerMC; | ||
import crafttweaker.api.world.IBlockPos; | ||
import crafttweaker.api.world.IWorld; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Vec3d; | ||
import net.minecraftforge.event.world.ExplosionEvent; | ||
|
||
public class MCExplosionEvent implements IExplosionEvent { | ||
private ExplosionEvent event; | ||
private Vec3d pos; | ||
private IBlockPos blockPos; | ||
|
||
public MCExplosionEvent(ExplosionEvent event) { | ||
this.event = event; | ||
this.pos = event.getExplosion().getPosition(); | ||
this.blockPos = CraftTweakerMC.getIBlockPos(new BlockPos(pos)); | ||
} | ||
|
||
@Override | ||
public IWorld getWorld() { | ||
return CraftTweakerMC.getIWorld(event.getWorld()); | ||
} | ||
|
||
@Override | ||
public IBlockPos getPosition() { | ||
return blockPos; | ||
} | ||
|
||
@Override | ||
public double getX() { | ||
return pos.x; | ||
} | ||
|
||
@Override | ||
public double getY() { | ||
return pos.y; | ||
} | ||
|
||
@Override | ||
public double getZ() { | ||
return pos.z; | ||
} | ||
|
||
@Override | ||
public boolean isCanceled() { | ||
return event.isCanceled(); | ||
} | ||
|
||
@Override | ||
public void setCanceled(boolean canceled) { | ||
event.setCanceled(canceled); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...-MC1120-Main/src/main/java/crafttweaker/mc1120/events/handling/MCExplosionStartEvent.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,13 @@ | ||
package crafttweaker.mc1120.events.handling; | ||
|
||
import crafttweaker.api.event.ExplosionStartEvent; | ||
import net.minecraftforge.event.world.ExplosionEvent; | ||
|
||
public class MCExplosionStartEvent extends MCExplosionEvent implements ExplosionStartEvent { | ||
private ExplosionEvent.Start event; | ||
|
||
public MCExplosionStartEvent(ExplosionEvent.Start event) { | ||
super(event); | ||
this.event = event; | ||
} | ||
} |