Skip to content

Commit

Permalink
Updated for 1.20
Browse files Browse the repository at this point in the history
- updated gradle settings for 1.20
- updated fabric.mod.josn for 1.20
- fixed compile errors that came with the update
  • Loading branch information
antD97 committed Dec 9, 2023
1 parent 23d061a commit 4b0b057
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 22 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.2
loader_version=0.15.0
minecraft_version=1.20
yarn_mappings=1.20+build.1
loader_version=0.15.1

# Mod Properties
mod_version = 1.0.0
maven_group = com.antd
archives_base_name = rail-transport-plus

# Dependencies
fabric_version=0.87.2+1.19.4
fabric_version=0.83.0+1.20
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;

import static com.antd.railtransportplus.RailTransportPlus.CART_VISUAL_STATE_PACKET_ID;

Expand All @@ -28,7 +29,7 @@ public void receive(
) {

// respond to request for cart visual state
final var cart = (AbstractMinecartEntity) player.getWorld().getEntity(buf.readUuid());
final var cart = (AbstractMinecartEntity) ((ServerWorld) player.getWorld()).getEntity(buf.readUuid());
final var rtpCart = (IRtpAbstractMinecartEntity) cart;

final var resBuf = PacketByteBufs.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void getMaxSpeed(CallbackInfoReturnable<Double> cir) {

@Inject(at = @At("HEAD"), method = "tick()V")
public void tickHead(CallbackInfo ci) {
if (!this.world.isClient()) {
if (!this.getWorld().isClient()) {
isTicked = false;
if (prevCart != null || nextCart != null) skipMove = true;
}
Expand All @@ -105,7 +105,7 @@ public void tickHead(CallbackInfo ci) {
@Inject(at = @At("RETURN"), method = "tick()V")
public void tickReturn(CallbackInfo ci) {

if (!this.world.isClient() && (prevCart != null || nextCart != null)) {
if (!this.getWorld().isClient() && (prevCart != null || nextCart != null)) {
isTicked = true;

// if all carts were ticked
Expand Down Expand Up @@ -184,7 +184,7 @@ public void tickReturn(CallbackInfo ci) {
// damage colliding entities
if (vel > 10) {

final var collidingEntities = cart.world
final var collidingEntities = cart.getWorld()
.getOtherEntities(
this,
cart.getBoundingBox().expand(0.05).stretch(this.getVelocity()),
Expand All @@ -198,7 +198,10 @@ public void tickReturn(CallbackInfo ci) {

for (final var e : collidingEntities) {
e.takeKnockback(vel * 0.1, cart.getX() - e.getX(), cart.getZ() - e.getZ());
e.damage(new DamageSource(world.getRegistryManager().get(RegistryKeys.DAMAGE_TYPE).entryOf(RailTransportPlus.TRAIN_DAMAGE)), (float) damage);
e.damage(new DamageSource(e.getWorld().getRegistryManager().get(RegistryKeys.DAMAGE_TYPE)
.entryOf(RailTransportPlus.TRAIN_DAMAGE)),
(float) damage
);
}
}
}
Expand Down Expand Up @@ -247,7 +250,7 @@ public void writeCustomDataToNbt(NbtCompound nbt, CallbackInfo ci) {
@Inject(at = @At("RETURN"), method = "readCustomDataFromNbt(Lnet/minecraft/nbt/NbtCompound;)V")
public void readCustomDataFromNbt(NbtCompound nbt, CallbackInfo ci) {
final var thisCart = (AbstractMinecartEntity) (Object) this;
final var world = (ServerWorld) thisCart.world;
final var world = (ServerWorld) thisCart.getWorld();

if (nbt.containsUuid("nextCart")) {
final var loadedUuid = nbt.getUuid("nextCart");
Expand Down Expand Up @@ -344,7 +347,7 @@ public void unlinkCart(AbstractMinecartEntity cart) {
((IRtpAbstractMinecartEntity) unlinkedCart).setPrevCart(null);

// item drop
if (this.world.getGameRules().get(GameRules.DO_ENTITY_DROPS).get()) this.dropItem(Items.CHAIN);
if (this.getWorld().getGameRules().get(GameRules.DO_ENTITY_DROPS).get()) this.dropItem(Items.CHAIN);

// sound
((AbstractMinecartEntity) (Object) this).playSound(SoundEvents.BLOCK_CHAIN_PLACE, 1.0F, 1.0F);
Expand All @@ -356,7 +359,7 @@ public void unlinkCart(AbstractMinecartEntity cart) {
((IRtpAbstractMinecartEntity) unlinkedCart).setNextCart(null);

// item drop
if (this.world.getGameRules().get(GameRules.DO_ENTITY_DROPS).get()) this.dropItem(Items.CHAIN);
if (this.getWorld().getGameRules().get(GameRules.DO_ENTITY_DROPS).get()) this.dropItem(Items.CHAIN);

// sound
((AbstractMinecartEntity) (Object) this).playSound(SoundEvents.BLOCK_CHAIN_PLACE, 1.0F, 1.0F);
Expand Down Expand Up @@ -491,7 +494,7 @@ public void updateVisualState() {

// send update to clients
if (oldVisualState != this.visualState) {
for (var player : ((ServerWorld) this.world).getPlayers()) {
for (var player : ((ServerWorld) this.getWorld()).getPlayers()) {

final var buf = PacketByteBufs.create();
buf.writeUuid(this.getUuid());
Expand All @@ -507,10 +510,10 @@ public void move(boolean isTrailing) {
var i = MathHelper.floor(this.getX());
var j = MathHelper.floor(this.getY());
var k = MathHelper.floor(this.getZ());
if (this.world.getBlockState(new BlockPos(i, j - 1, k)).isIn(BlockTags.RAILS)) --j;
if (this.getWorld().getBlockState(new BlockPos(i, j - 1, k)).isIn(BlockTags.RAILS)) --j;

final var blockPos = new BlockPos(i, j, k);
final var blockState = this.world.getBlockState(blockPos);
final var blockState = this.getWorld().getBlockState(blockPos);
if (AbstractRailBlock.isRail(blockState)) {

if (isTrailing) { // trailing carts ignore powered rails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public abstract class EntityMixin {
public void remove(Entity.RemovalReason reason, CallbackInfo ci) {
final var thisEntity = (Entity) (Object) this;

if (!thisEntity.world.isClient() && this instanceof final IRtpAbstractMinecartEntity thisCart) {
if (!thisEntity.getWorld().isClient() && this instanceof final IRtpAbstractMinecartEntity thisCart) {
thisCart.unlinkBothCarts();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected FurnaceMinecartEntityMixin(EntityType<?> entityType, World world) {
@Inject(at = @At("RETURN"), method = "tick()V")
public void tick(CallbackInfo ci) {

if (!this.world.isClient()) {
if (!this.getWorld().isClient()) {

// try refueling from chest cart
if (this.fuel <= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected PlayerEntityMixin(EntityType<? extends LivingEntity> entityType, World
@Inject(at = @At("HEAD"), method = "tick()V")
public void tick(CallbackInfo ci) {

if (!this.world.isClient()) {
if (!this.getWorld().isClient()) {
final var thisPlayer = (ServerPlayerEntity) (Object) this;

// linking cart message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface VehicleInventoryMixin extends IRtpVehicleInventory {

@Inject(at = @At("HEAD"), method = "open", cancellable = true)
default void open(PlayerEntity player, CallbackInfoReturnable<ActionResult> cir) {
if (!player.world.isClient) {
if (!player.getWorld().isClient) {
final var rtpStorageCart = ((IRtpStorageMinecartEntity) this);

if (rtpStorageCart.getSkipNextOpen()) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
],

"depends": {
"fabricloader": ">=0.14.11",
"fabric-api": "*",
"minecraft": "~1.19.2",
"fabricloader": ">=0.15.1",
"fabric-api": ">=0.83.0",
"minecraft": "1.20",
"java": ">=17"
}
}

0 comments on commit 4b0b057

Please sign in to comment.