diff --git a/common/src/main/java/com/mrcrayfish/goblintraders/entity/AbstractGoblinEntity.java b/common/src/main/java/com/mrcrayfish/goblintraders/entity/AbstractGoblinEntity.java index 989fd56..6a0dfa0 100644 --- a/common/src/main/java/com/mrcrayfish/goblintraders/entity/AbstractGoblinEntity.java +++ b/common/src/main/java/com/mrcrayfish/goblintraders/entity/AbstractGoblinEntity.java @@ -152,10 +152,10 @@ public void baseTick() if(this.stunDelay == 0) { this.entityData.set(STUNNED, false); - this.level.playSound(null, this.getX(), this.getY(), this.getZ(), ModSounds.ENTITY_GOBLIN_TRADER_ANNOYED_GRUNT.get(), SoundSource.NEUTRAL, 1.0F, 0.9F + this.getRandom().nextFloat() * 0.2F); + this.level().playSound(null, this.getX(), this.getY(), this.getZ(), ModSounds.ENTITY_GOBLIN_TRADER_ANNOYED_GRUNT.get(), SoundSource.NEUTRAL, 1.0F, 0.9F + this.getRandom().nextFloat() * 0.2F); } } - if(!this.level.isClientSide() && (!Config.ENTITIES.preventDespawnIfNamed.get() || !this.isPersistenceRequired())) + if(!this.level().isClientSide() && (!Config.ENTITIES.preventDespawnIfNamed.get() || !this.isPersistenceRequired())) { this.handleDespawn(); } @@ -170,7 +170,7 @@ else if(this.entityData.get(STUNNED)) { this.fallCounter = 0; } - if(!this.level.isClientSide() && this.getMaxRestockDelay() != -1) + if(!this.level().isClientSide() && this.getMaxRestockDelay() != -1) { if(++this.restockDelay >= this.getMaxRestockDelay()) { @@ -243,9 +243,9 @@ public void notifyTrade(MerchantOffer offer) { this.tradedCustomers.add(this.customer.getUUID()); } - if(this.level instanceof ServerLevel) + if(this.level() instanceof ServerLevel serverLevel) { - ExperienceOrb.award((ServerLevel) this.level, this.getPosition(1F), offer.getXp()); + ExperienceOrb.award(serverLevel, this.getPosition(1F), offer.getXp()); } } @@ -255,16 +255,10 @@ public void notifyTradeUpdated(ItemStack stack) } - @Override - public Level getLevel() - { - return this.level; - } - @Override public boolean isClientSide() { - return this.getLevel().isClientSide; + return this.level().isClientSide(); } @Override @@ -307,14 +301,14 @@ else if(this.isAlive() && !this.hasCustomer() && !this.isBaby() && (this.fireImm { if(this.getOffers().isEmpty()) { - return InteractionResult.sidedSuccess(this.level.isClientSide()); + return InteractionResult.sidedSuccess(this.isClientSide()); } - else if(!this.level.isClientSide() && (this.getLastHurtByMob() == null || this.getLastHurtByMob() != player)) + else if(!this.isClientSide() && (this.getLastHurtByMob() == null || this.getLastHurtByMob() != player)) { this.setTradingPlayer(player); this.openTradingScreen(player, this.getDisplayName(), 1); } - return InteractionResult.sidedSuccess(this.level.isClientSide()); + return InteractionResult.sidedSuccess(this.isClientSide()); } return super.mobInteract(player, hand); } @@ -326,7 +320,7 @@ protected void triggerItemUseEffects(ItemStack stack, int count) { if(stack.getUseAnimation() == UseAnim.DRINK) { - this.playSound(this.getDrinkingSound(stack), 0.5F, this.level.getRandom().nextFloat() * 0.1F + 0.9F); + this.playSound(this.getDrinkingSound(stack), 0.5F, this.level().getRandom().nextFloat() * 0.1F + 0.9F); } if(stack.getUseAnimation() == UseAnim.EAT) { @@ -347,13 +341,13 @@ protected void spawnFoodParticles(ItemStack stack, int count) frontPosition = frontPosition.add(0, 0.35, 0); frontPosition = frontPosition.add(this.position()); Vec3 motion = new Vec3(this.getRandom().nextDouble() * 0.2 - 0.1, 0.1, this.getRandom().nextDouble() * 0.2 - 0.1); - if(this.level instanceof ServerLevel) + if(this.level() instanceof ServerLevel serverLevel) { - ((ServerLevel) this.level).sendParticles(new ItemParticleOption(ParticleTypes.ITEM, stack), frontPosition.x, frontPosition.y, frontPosition.z, 1, motion.x, motion.y + 0.05D, motion.z, 0.0D); + serverLevel.sendParticles(new ItemParticleOption(ParticleTypes.ITEM, stack), frontPosition.x, frontPosition.y, frontPosition.z, 1, motion.x, motion.y + 0.05D, motion.z, 0.0D); } else { - this.level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, stack), frontPosition.x, frontPosition.y, frontPosition.z, motion.x, motion.y + 0.05D, motion.z); + this.level().addParticle(new ItemParticleOption(ParticleTypes.ITEM, stack), frontPosition.x, frontPosition.y, frontPosition.z, motion.x, motion.y + 0.05D, motion.z); } } } diff --git a/common/src/main/java/com/mrcrayfish/goblintraders/entity/VeinGoblinTrader.java b/common/src/main/java/com/mrcrayfish/goblintraders/entity/VeinGoblinTrader.java index c2618e2..549b514 100644 --- a/common/src/main/java/com/mrcrayfish/goblintraders/entity/VeinGoblinTrader.java +++ b/common/src/main/java/com/mrcrayfish/goblintraders/entity/VeinGoblinTrader.java @@ -67,9 +67,9 @@ public ItemStack getFavouriteFood() @Override public void aiStep() { - if(this.level.isClientSide() && this.tickCount % 2 == 0) + if(this.isClientSide() && this.tickCount % 2 == 0) { - this.level.addParticle(ParticleTypes.FLAME, this.getX() - 0.5 + this.getRandom().nextDouble(), this.getY() + 0.5 - 0.5 + this.getRandom().nextDouble(), this.getZ() - 0.5 + this.getRandom().nextDouble(), 0, 0, 0); + this.level().addParticle(ParticleTypes.FLAME, this.getX() - 0.5 + this.getRandom().nextDouble(), this.getY() + 0.5 - 0.5 + this.getRandom().nextDouble(), this.getZ() - 0.5 + this.getRandom().nextDouble(), 0, 0, 0); } super.aiStep(); } diff --git a/common/src/main/java/com/mrcrayfish/goblintraders/entity/ai/goal/FindFavouriteFoodGoal.java b/common/src/main/java/com/mrcrayfish/goblintraders/entity/ai/goal/FindFavouriteFoodGoal.java index 1d357ca..9ebadcc 100644 --- a/common/src/main/java/com/mrcrayfish/goblintraders/entity/ai/goal/FindFavouriteFoodGoal.java +++ b/common/src/main/java/com/mrcrayfish/goblintraders/entity/ai/goal/FindFavouriteFoodGoal.java @@ -47,7 +47,7 @@ public void tick() if(this.entity.distanceTo(this.itemEntity) <= 1.0D && this.itemEntity.isAlive()) { this.itemEntity.remove(Entity.RemovalReason.KILLED); - this.entity.level.playSound(null, this.itemEntity.getX(), this.itemEntity.getY(), this.itemEntity.getZ(), SoundEvents.ITEM_PICKUP, SoundSource.NEUTRAL, 1.0F, 0.75F); + this.entity.level().playSound(null, this.itemEntity.getX(), this.itemEntity.getY(), this.itemEntity.getZ(), SoundEvents.ITEM_PICKUP, SoundSource.NEUTRAL, 1.0F, 0.75F); } } @@ -60,7 +60,7 @@ public boolean canContinueToUse() @Nullable private void findFavouriteFood() { - List players = this.entity.level.getEntitiesOfClass(ItemEntity.class, this.entity.getBoundingBox().inflate(10), itemEntity -> itemEntity.getItem().getItem() == this.entity.getFavouriteFood().getItem()); + List players = this.entity.level().getEntitiesOfClass(ItemEntity.class, this.entity.getBoundingBox().inflate(10), itemEntity -> itemEntity.getItem().getItem() == this.entity.getFavouriteFood().getItem()); if(players.size() > 0) { this.itemEntity = players.stream().min(Comparator.comparing(this.entity::distanceTo)).get(); diff --git a/common/src/main/java/com/mrcrayfish/goblintraders/entity/ai/goal/FirePanicGoal.java b/common/src/main/java/com/mrcrayfish/goblintraders/entity/ai/goal/FirePanicGoal.java index e348a9a..c969175 100644 --- a/common/src/main/java/com/mrcrayfish/goblintraders/entity/ai/goal/FirePanicGoal.java +++ b/common/src/main/java/com/mrcrayfish/goblintraders/entity/ai/goal/FirePanicGoal.java @@ -35,7 +35,7 @@ public boolean canUse() { if(this.goblin.isOnFire() && !this.goblin.isStunned()) { - BlockPos blockpos = this.getClosestWaterPos(this.goblin.level, this.goblin, 5, 4); + BlockPos blockpos = this.getClosestWaterPos(this.goblin.level(), this.goblin, 5, 4); if(blockpos != null) { this.randPosX = (double) blockpos.getX(); diff --git a/common/src/main/java/com/mrcrayfish/goblintraders/entity/ai/goal/FollowPotentialCustomerGoal.java b/common/src/main/java/com/mrcrayfish/goblintraders/entity/ai/goal/FollowPotentialCustomerGoal.java index f248461..a7d36fe 100644 --- a/common/src/main/java/com/mrcrayfish/goblintraders/entity/ai/goal/FollowPotentialCustomerGoal.java +++ b/common/src/main/java/com/mrcrayfish/goblintraders/entity/ai/goal/FollowPotentialCustomerGoal.java @@ -74,7 +74,7 @@ public void stop() @Nullable private void findCustomer() { - List players = this.entity.level.getEntitiesOfClass(Player.class, this.entity.getBoundingBox().inflate(10), playerEntity -> !playerEntity.isCreative() && !playerEntity.isSpectator()); + List players = this.entity.level().getEntitiesOfClass(Player.class, this.entity.getBoundingBox().inflate(10), playerEntity -> !playerEntity.isCreative() && !playerEntity.isSpectator()); if(players.size() > 0) { this.potentialCustomer = players.stream().min(Comparator.comparing(this.entity::distanceTo)).get(); diff --git a/common/src/main/java/com/mrcrayfish/goblintraders/entity/ai/goal/TradeWithPlayerGoal.java b/common/src/main/java/com/mrcrayfish/goblintraders/entity/ai/goal/TradeWithPlayerGoal.java index af28563..cd38dcb 100644 --- a/common/src/main/java/com/mrcrayfish/goblintraders/entity/ai/goal/TradeWithPlayerGoal.java +++ b/common/src/main/java/com/mrcrayfish/goblintraders/entity/ai/goal/TradeWithPlayerGoal.java @@ -30,7 +30,7 @@ else if(this.entity.isInWater()) { return false; } - else if(!this.entity.isOnGround()) + else if(!this.entity.onGround()) { return false; } diff --git a/common/src/main/java/com/mrcrayfish/goblintraders/trades/GoblinMerchantOffer.java b/common/src/main/java/com/mrcrayfish/goblintraders/trades/GoblinMerchantOffer.java index eaa3973..bca88c0 100644 --- a/common/src/main/java/com/mrcrayfish/goblintraders/trades/GoblinMerchantOffer.java +++ b/common/src/main/java/com/mrcrayfish/goblintraders/trades/GoblinMerchantOffer.java @@ -42,7 +42,7 @@ private boolean isMatching(ItemStack given, ItemStack payment) givenCopy.setDamageValue(givenCopy.getDamageValue()); } - if(!ItemStack.isSame(givenCopy, payment)) + if(!ItemStack.isSameItem(givenCopy, payment)) return false; if(!payment.hasTag()) diff --git a/fabric/build.gradle b/fabric/build.gradle index 45e7d3b..f4aa100 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -34,6 +34,7 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}" modImplementation "com.mrcrayfish:framework-fabric:${minecraft_version}-${framework_version}" + modRuntimeOnly "com.mrcrayfish:catalogue-fabric:${minecraft_version}-1.7.1" implementation "com.google.code.findbugs:jsr305:3.0.2" implementation project(":common") testModImplementation sourceSets.main.output diff --git a/forge/build.gradle b/forge/build.gradle index 8938a20..42714f6 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -79,7 +79,7 @@ configurations { dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation fg.deobf("com.mrcrayfish:framework-forge:${minecraft_version}-${framework_version}") - runtimeOnly fg.deobf("com.mrcrayfish:catalogue-forge:${minecraft_version}-1.7.0") + runtimeOnly fg.deobf("com.mrcrayfish:catalogue-forge:${minecraft_version}-1.7.1") compileOnly project(":common") testCompileOnly project(":common") annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT:processor") diff --git a/forge/src/main/java/com/mrcrayfish/goblintraders/GoblinTraders.java b/forge/src/main/java/com/mrcrayfish/goblintraders/GoblinTraders.java index bc1f8f6..77c3559 100644 --- a/forge/src/main/java/com/mrcrayfish/goblintraders/GoblinTraders.java +++ b/forge/src/main/java/com/mrcrayfish/goblintraders/GoblinTraders.java @@ -30,8 +30,9 @@ public GoblinTraders() { IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); bus.addListener(this::onCommonSetup); + bus.addListener(this::onClientSetup); bus.addListener(this::onGatherData); - MinecraftForge.EVENT_BUS.addListener(this::onEntityAttributeCreation); + bus.addListener(this::onEntityAttributeCreation); MinecraftForge.EVENT_BUS.addListener(this::addReloadListener); } diff --git a/forge/src/main/java/com/mrcrayfish/goblintraders/client/ClientHandler.java b/forge/src/main/java/com/mrcrayfish/goblintraders/client/ClientHandler.java index ef2b976..22c886d 100644 --- a/forge/src/main/java/com/mrcrayfish/goblintraders/client/ClientHandler.java +++ b/forge/src/main/java/com/mrcrayfish/goblintraders/client/ClientHandler.java @@ -9,7 +9,7 @@ import net.minecraft.world.item.CreativeModeTabs; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.EntityRenderersEvent; -import net.minecraftforge.event.CreativeModeTabEvent; +import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -34,9 +34,9 @@ public static void registerEntityRenderers(EntityRenderersEvent.RegisterLayerDef } @SubscribeEvent - public static void onRegisterCreativeTab(CreativeModeTabEvent.BuildContents event) + public static void onRegisterCreativeTab(BuildCreativeModeTabContentsEvent event) { - if(event.getTab().equals(CreativeModeTabs.SPAWN_EGGS)) + if(event.getTabKey().equals(CreativeModeTabs.SPAWN_EGGS)) { event.accept(ModItems.GOBLIN_TRADER_SPAWN_EGG.get()); event.accept(ModItems.VEIN_GOBLIN_TRADER_SPAWN_EGG.get()); diff --git a/gradle.properties b/gradle.properties index ef5e788..dbc0710 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,13 +2,13 @@ group=com.mrcrayfish # Common -minecraft_version=1.19.4 +minecraft_version=1.20.1 # Forge -forge_version=45.1.0 +forge_version=47.0.43 # Fabric -fabric_version=0.87.0+1.19.4 +fabric_version=0.87.0+1.20.1 fabric_loader_version=0.14.22 # Mod options