mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 12:20:11 +00:00
1.20.2-pre1
This commit is contained in:
368 files changed
+3555
-6356
No files matched your search
@@ -7,11 +7,7 @@ package net.minecraftforge.event.entity;
|
||||
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.extensions.IForgeEntity;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
/**
|
||||
@@ -23,17 +19,14 @@ import net.minecraftforge.eventbus.api.Event;
|
||||
* <br>
|
||||
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.<br>
|
||||
**/
|
||||
public class EntityEvent extends Event
|
||||
{
|
||||
public class EntityEvent extends Event {
|
||||
private final Entity entity;
|
||||
|
||||
public EntityEvent(Entity entity)
|
||||
{
|
||||
public EntityEvent(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public Entity getEntity()
|
||||
{
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -47,10 +40,8 @@ public class EntityEvent extends Event
|
||||
* <br>
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
|
||||
**/
|
||||
public static class EntityConstructing extends EntityEvent
|
||||
{
|
||||
public EntityConstructing(Entity entity)
|
||||
{
|
||||
public static class EntityConstructing extends EntityEvent {
|
||||
public EntityConstructing(Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
}
|
||||
@@ -67,14 +58,11 @@ public class EntityEvent extends Event
|
||||
* <br>
|
||||
* This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}.<br>
|
||||
**/
|
||||
public static class EnteringSection extends EntityEvent
|
||||
{
|
||||
|
||||
public static class EnteringSection extends EntityEvent {
|
||||
private final long packedOldPos;
|
||||
private final long packedNewPos;
|
||||
|
||||
public EnteringSection(Entity entity, long packedOldPos, long packedNewPos)
|
||||
{
|
||||
public EnteringSection(Entity entity, long packedOldPos, long packedNewPos) {
|
||||
super(entity);
|
||||
this.packedOldPos = packedOldPos;
|
||||
this.packedNewPos = packedNewPos;
|
||||
@@ -85,8 +73,7 @@ public class EntityEvent extends Event
|
||||
* such as {@link SectionPos#of(long)} or {@link SectionPos#x(long)} to avoid allocation.
|
||||
* @return the packed position of the old section
|
||||
*/
|
||||
public long getPackedOldPos()
|
||||
{
|
||||
public long getPackedOldPos() {
|
||||
return packedOldPos;
|
||||
}
|
||||
|
||||
@@ -95,24 +82,21 @@ public class EntityEvent extends Event
|
||||
* such as {@link SectionPos#of(long)} or {@link SectionPos#x(long)} to avoid allocation.
|
||||
* @return the packed position of the new section
|
||||
*/
|
||||
public long getPackedNewPos()
|
||||
{
|
||||
public long getPackedNewPos() {
|
||||
return packedNewPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the position of the old section
|
||||
*/
|
||||
public SectionPos getOldPos()
|
||||
{
|
||||
public SectionPos getOldPos() {
|
||||
return SectionPos.of(packedOldPos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the position of the new section
|
||||
*/
|
||||
public SectionPos getNewPos()
|
||||
{
|
||||
public SectionPos getNewPos() {
|
||||
return SectionPos.of(packedNewPos);
|
||||
}
|
||||
|
||||
@@ -120,87 +104,8 @@ public class EntityEvent extends Event
|
||||
* Whether the chunk has changed as part of this event. If this method returns false, only the Y position of the
|
||||
* section has changed.
|
||||
*/
|
||||
public boolean didChunkChange()
|
||||
{
|
||||
public boolean didChunkChange() {
|
||||
return SectionPos.x(packedOldPos) != SectionPos.x(packedNewPos) || SectionPos.z(packedOldPos) != SectionPos.z(packedNewPos);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* CAREFUL: This is also fired in the Entity constructor. Therefore, the entity (subclass) might not be fully initialized. Check {@link Entity#isAddedToWorld()} or {@code !Entity.firstUpdate}.<br>
|
||||
* If you change the player's size, you probably want to set the eye height accordingly as well<br>
|
||||
* <br>
|
||||
* This event is not {@link Cancelable}.<br>
|
||||
* <br>
|
||||
* This event does not have a result. {@link HasResult}
|
||||
* <br>
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
|
||||
**/
|
||||
@Deprecated(forRemoval = true, since = "1.20.1") // Remove Entity Eye/Size hooks, as they need to be redesigned
|
||||
public static class Size extends EntityEvent {
|
||||
private final Pose pose;
|
||||
private final EntityDimensions originalSize;
|
||||
private EntityDimensions newSize;
|
||||
private final float oldEyeHeight;
|
||||
private float newEyeHeight;
|
||||
|
||||
public Size(Entity entity, Pose pose, EntityDimensions size) {
|
||||
this(entity, pose, size, 1.0f); // Eye height doesn't matter this is just for binary compatibility.
|
||||
}
|
||||
|
||||
public Size(Entity entity, Pose pose, EntityDimensions size, float defaultEyeHeight) {
|
||||
this(entity, pose, size, size, defaultEyeHeight, defaultEyeHeight);
|
||||
}
|
||||
|
||||
public Size(Entity entity, Pose pose, EntityDimensions oldSize, EntityDimensions newSize, float oldEyeHeight, float newEyeHeight) {
|
||||
super(entity);
|
||||
this.pose = pose;
|
||||
this.originalSize = oldSize;
|
||||
this.newSize = newSize;
|
||||
this.oldEyeHeight = oldEyeHeight;
|
||||
this.newEyeHeight = newEyeHeight;
|
||||
}
|
||||
|
||||
public Pose getPose() { return pose; }
|
||||
public EntityDimensions getOldSize() { return this.getOriginalSize(); }
|
||||
public EntityDimensions getOriginalSize() { return originalSize; }
|
||||
public EntityDimensions getNewSize() { return newSize; }
|
||||
public void setNewSize(EntityDimensions size) { this.newSize = size; }
|
||||
|
||||
public void setNewSize(EntityDimensions size, boolean updateEyeHeight) {
|
||||
this.setNewSize(size);
|
||||
if (updateEyeHeight) {
|
||||
this.newEyeHeight = this.getEntity().getEyeHeightAccess(this.getPose(), this.newSize);
|
||||
}
|
||||
}
|
||||
public float getOldEyeHeight() { return oldEyeHeight; }
|
||||
public float getNewEyeHeight() { return newEyeHeight; }
|
||||
public void setNewEyeHeight(float eyeHeight) { this.newEyeHeight = eyeHeight; }
|
||||
}
|
||||
|
||||
/**
|
||||
*Remove Entity Eye/Size hooks, as they need to be redesigned, this is no longer fired in any forge/vanilla code.
|
||||
**/
|
||||
@Deprecated(forRemoval = true, since = "1.20.1")
|
||||
public static class EyeHeight extends EntityEvent {
|
||||
private final Pose pose;
|
||||
private final EntityDimensions size;
|
||||
private final float originalEyeHeight;
|
||||
private float newEyeHeight;
|
||||
|
||||
public EyeHeight(Entity entity, Pose pose, EntityDimensions size, float eyeHeight) {
|
||||
super(entity);
|
||||
this.pose = pose;
|
||||
this.size = size;
|
||||
this.originalEyeHeight = eyeHeight;
|
||||
this.newEyeHeight = eyeHeight;
|
||||
}
|
||||
|
||||
public Pose getPose() { return pose; }
|
||||
public EntityDimensions getSize() { return size; }
|
||||
public float getOriginalEyeHeight() { return originalEyeHeight; }
|
||||
public float getNewEyeHeight() { return newEyeHeight; }
|
||||
public void setNewEyeHeight(float newEyeHeight) { this.newEyeHeight = newEyeHeight; }
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import net.minecraft.world.entity.projectile.Projectile;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
@@ -20,58 +19,38 @@ import java.util.Objects;
|
||||
* This event is fired via {@link ForgeEventFactory#onProjectileImpact(Projectile, HitResult)}
|
||||
* This event is fired for all vanilla projectiles by Forge,
|
||||
* custom projectiles should fire this event and check the result in a similar fashion.
|
||||
* This event is cancelable. When canceled, the impact will not be processed and the projectile will continue flying.
|
||||
* Killing or other handling of the entity after event cancellation is up to the modder.
|
||||
* You can also directly set the {@link ImpactResult} to change the impact behaviour.
|
||||
* @see #setImpactResult(ImpactResult)
|
||||
*/
|
||||
@Cancelable
|
||||
public class ProjectileImpactEvent extends EntityEvent
|
||||
{
|
||||
public class ProjectileImpactEvent extends EntityEvent {
|
||||
private final HitResult ray;
|
||||
private final Projectile projectile;
|
||||
|
||||
private ImpactResult result = ImpactResult.DEFAULT;
|
||||
|
||||
public ProjectileImpactEvent(Projectile projectile, HitResult ray)
|
||||
{
|
||||
public ProjectileImpactEvent(Projectile projectile, HitResult ray) {
|
||||
super(projectile);
|
||||
this.ray = ray;
|
||||
this.projectile = projectile;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated Use {@link #setImpactResult(ImpactResult)} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.20.1")
|
||||
public void setCanceled(boolean cancel)
|
||||
{
|
||||
super.setCanceled(cancel);
|
||||
}
|
||||
|
||||
public HitResult getRayTraceResult()
|
||||
{
|
||||
public HitResult getRayTraceResult() {
|
||||
return ray;
|
||||
}
|
||||
|
||||
public Projectile getProjectile()
|
||||
{
|
||||
public Projectile getProjectile() {
|
||||
return projectile;
|
||||
}
|
||||
|
||||
public void setImpactResult(@NotNull ImpactResult newResult)
|
||||
{
|
||||
public void setImpactResult(@NotNull ImpactResult newResult) {
|
||||
this.result = Objects.requireNonNull(newResult, "ImpactResult cannot be null");
|
||||
}
|
||||
|
||||
public ImpactResult getImpactResult()
|
||||
{
|
||||
public ImpactResult getImpactResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public enum ImpactResult
|
||||
{
|
||||
public enum ImpactResult {
|
||||
/**
|
||||
* The default behaviour, the projectile will be destroyed and the hit will be processed.
|
||||
*/
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package net.minecraftforge.event.entity.player;
|
||||
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import net.minecraft.advancements.AdvancementProgress;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -15,18 +16,15 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
* @see AdvancementEarnEvent
|
||||
* @see AdvancementProgressEvent
|
||||
*/
|
||||
public class AdvancementEvent extends PlayerEvent
|
||||
{
|
||||
private final Advancement advancement;
|
||||
public class AdvancementEvent extends PlayerEvent {
|
||||
private final AdvancementHolder advancement;
|
||||
|
||||
public AdvancementEvent(Player player, Advancement advancement)
|
||||
{
|
||||
public AdvancementEvent(Player player, AdvancementHolder advancement) {
|
||||
super(player);
|
||||
this.advancement = advancement;
|
||||
}
|
||||
|
||||
public Advancement getAdvancement()
|
||||
{
|
||||
public AdvancementHolder getAdvancement() {
|
||||
return advancement;
|
||||
}
|
||||
|
||||
@@ -43,23 +41,10 @@ public class AdvancementEvent extends PlayerEvent
|
||||
*
|
||||
* @see AdvancementProgress#isDone()
|
||||
*/
|
||||
public static class AdvancementEarnEvent extends AdvancementEvent
|
||||
{
|
||||
|
||||
public AdvancementEarnEvent(Player player, Advancement earned)
|
||||
{
|
||||
public static class AdvancementEarnEvent extends AdvancementEvent {
|
||||
public AdvancementEarnEvent(Player player, AdvancementHolder earned) {
|
||||
super(player, earned);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@return the advancement that was earned}
|
||||
*/
|
||||
@Override
|
||||
public Advancement getAdvancement()
|
||||
{
|
||||
return super.getAdvancement();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,56 +59,40 @@ public class AdvancementEvent extends PlayerEvent
|
||||
* @see net.minecraft.server.PlayerAdvancements#award(Advancement, String)
|
||||
* @see net.minecraft.server.PlayerAdvancements#revoke(Advancement, String)
|
||||
*/
|
||||
public static class AdvancementProgressEvent extends AdvancementEvent
|
||||
{
|
||||
public static class AdvancementProgressEvent extends AdvancementEvent {
|
||||
private final AdvancementProgress advancementProgress;
|
||||
private final String criterionName;
|
||||
private final AdvancementEvent.AdvancementProgressEvent.ProgressType progressType;
|
||||
|
||||
public AdvancementProgressEvent(Player player, Advancement progressed, AdvancementProgress advancementProgress, String criterionName, AdvancementEvent.AdvancementProgressEvent.ProgressType progressType)
|
||||
{
|
||||
public AdvancementProgressEvent(Player player, AdvancementHolder progressed, AdvancementProgress advancementProgress, String criterionName, AdvancementEvent.AdvancementProgressEvent.ProgressType progressType) {
|
||||
super(player, progressed);
|
||||
this.advancementProgress = advancementProgress;
|
||||
this.criterionName = criterionName;
|
||||
this.progressType = progressType;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@return The advancement that was progressed}
|
||||
*/
|
||||
@Override
|
||||
public Advancement getAdvancement()
|
||||
{
|
||||
return super.getAdvancement();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the progress of the advancement}
|
||||
*/
|
||||
public AdvancementProgress getAdvancementProgress()
|
||||
{
|
||||
public AdvancementProgress getAdvancementProgress() {
|
||||
return advancementProgress;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return name of the criterion that was progressed}
|
||||
*/
|
||||
public String getCriterionName()
|
||||
{
|
||||
public String getCriterionName() {
|
||||
return criterionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return The type of progress for the criterion in this event}
|
||||
*/
|
||||
public ProgressType getProgressType()
|
||||
{
|
||||
public ProgressType getProgressType() {
|
||||
return progressType;
|
||||
}
|
||||
|
||||
public enum ProgressType
|
||||
{
|
||||
public enum ProgressType {
|
||||
GRANT, REVOKE
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user