Merge branch 'master' into 1.16
This commit is contained in:
commit
9035dd08c6
5 files changed
+44
-3
No files matched your search
@@ -7,4 +7,8 @@ public interface EntityInterface
|
||||
float getMainYaw(float partialTicks);
|
||||
|
||||
EntityEventsGroup getEventContainer();
|
||||
|
||||
boolean isPermanentVehicle();
|
||||
|
||||
void setPermanentVehicle(boolean permanent);
|
||||
}
|
||||
@@ -14,6 +14,8 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface
|
||||
{
|
||||
@Shadow public boolean removed;
|
||||
|
||||
private boolean permanentVehicle;
|
||||
|
||||
private final EntityEventsGroup events = new EntityEventsGroup();
|
||||
|
||||
@Override
|
||||
@@ -22,6 +24,18 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface
|
||||
return events;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermanentVehicle()
|
||||
{
|
||||
return permanentVehicle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPermanentVehicle(boolean permanent)
|
||||
{
|
||||
permanentVehicle = permanent;
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
private void onTickCall(CallbackInfo ci)
|
||||
{
|
||||
@@ -34,4 +48,6 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface
|
||||
{
|
||||
if (!removed) events.onEvent(EntityEventsGroup.EntityEventType.ON_REMOVED, (Entity) (Object) this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.EntityInterface;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -53,4 +54,14 @@ public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity
|
||||
{
|
||||
STATISTICS.onPlayerStatistic((ServerPlayerEntity) (Object)this, stat, amount);
|
||||
}
|
||||
|
||||
@Redirect(method = "method_14218", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;setSneaking(Z)V"
|
||||
))
|
||||
private void setSneakingConditionally(ServerPlayerEntity serverPlayerEntity, boolean sneaking)
|
||||
{
|
||||
if (!((EntityInterface)serverPlayerEntity.getVehicle()).isPermanentVehicle()) // won't since that method makes sure its not null
|
||||
serverPlayerEntity.setSneaking(sneaking);
|
||||
}
|
||||
}
|
||||
@@ -2244,9 +2244,12 @@ public class CarpetExpression
|
||||
* <h3><code>modify(e, 'accelerate', x, y, z), modify(e, 'accelerate', l(x, y, z) )</code></h3>
|
||||
* <p>Adds a vector to the motion vector. Most realistic way to apply a force to an entity.</p>
|
||||
* <h3><code>modify(e, 'custom_name'), modify(e, 'custom_name', name )</code></h3>
|
||||
* <h3><code>modify(e, 'pickup_delay')</code></h3>
|
||||
* <h3><code>modify(e, 'breeding_age')</code></h3>
|
||||
* <h3><code>modify(e, 'despawn_timer')</code></h3>
|
||||
* <h3><code>modify(e, 'age', number)</code></h3>
|
||||
* <p>Modifies entity's internal age counter. Fiddling with this will affect directly
|
||||
* behaviours of complex entities, so use it with caution.</p>
|
||||
* <h3><code>modify(e, 'pickup_delay', number)</code></h3>
|
||||
* <h3><code>modify(e, 'breeding_age', number)</code></h3>
|
||||
* <h3><code>modify(e, 'despawn_timer', number)</code></h3>
|
||||
* <p>Sets a custom despawn timer value.</p>
|
||||
* <h3><code>modify(e, 'dismount')</code></h3>
|
||||
* <p>Dismounts riding entity.</p>
|
||||
|
||||
@@ -228,6 +228,7 @@ public class EntityValue extends Value
|
||||
put("is_ridden", (e, a) -> new NumericValue(e.hasPassengers()));
|
||||
put("passengers", (e, a) -> ListValue.wrap(e.getPassengerList().stream().map(EntityValue::new).collect(Collectors.toList())));
|
||||
put("mount", (e, a) -> (e.getVehicle()!=null)?new EntityValue(e.getVehicle()):Value.NULL);
|
||||
put("unmountable", (e, a) -> new NumericValue(((EntityInterface)e).isPermanentVehicle()));
|
||||
put("tags", (e, a) -> ListValue.wrap(e.getScoreboardTags().stream().map(StringValue::new).collect(Collectors.toList())));
|
||||
put("has_tag", (e, a) -> new NumericValue(e.getScoreboardTags().contains(a.getString())));
|
||||
put("yaw", (e, a)-> new NumericValue(e.yaw));
|
||||
@@ -517,6 +518,7 @@ public class EntityValue extends Value
|
||||
|
||||
private static final Map<String, BiConsumer<Entity, Value>> featureModifiers = new HashMap<String, BiConsumer<Entity, Value>>() {{
|
||||
put("remove", (entity, value) -> entity.remove());
|
||||
put("age", (e, v) -> e.age = Math.abs((int)NumericValue.asNumber(v).getLong()) );
|
||||
put("health", (e, v) -> { if (e instanceof LivingEntity) ((LivingEntity) e).setHealth((float) NumericValue.asNumber(v).getDouble()); });
|
||||
put("kill", (e, v) -> e.kill());
|
||||
put("location", (e, v) ->
|
||||
@@ -660,6 +662,11 @@ public class EntityValue extends Value
|
||||
//...
|
||||
}
|
||||
});
|
||||
put("unmountable", (e, v) ->{
|
||||
if (v == null)
|
||||
v = Value.TRUE;
|
||||
((EntityInterface)e).setPermanentVehicle(v.getBoolean());
|
||||
});
|
||||
put("drop_passengers", (e, v) -> e.removeAllPassengers());
|
||||
put("mount_passengers", (e, v) -> {
|
||||
if (v==null)
|
||||
|
||||
Reference in new issue
Block a user