Skip to content

Commit

Permalink
update to 1.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ewewukek committed Feb 24, 2024
1 parent 11ef27f commit 803f544
Show file tree
Hide file tree
Showing 17 changed files with 93 additions and 57 deletions.
11 changes: 11 additions & 0 deletions fabric/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,14 @@ bin/
# macos

*.DS_Store

# fabric

run/

# java

hs_err_*.log
replay_*.log
*.hprof
*.jfr
Binary file modified fabric/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion fabric/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
32 changes: 21 additions & 11 deletions fabric/src/main/java/ewewukek/musketmod/MusketMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.concurrent.Executor;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.fabricmc.fabric.api.networking.v1.PlayerLookup;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
Expand All @@ -14,6 +15,7 @@
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
Expand All @@ -26,6 +28,7 @@
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.phys.Vec3;

public class MusketMod implements ModInitializer {
Expand All @@ -42,19 +45,26 @@ public class MusketMod implements ModInitializer {
public void onInitialize() {
Config.reload();

Registry.register(Registry.ITEM, new ResourceLocation(MODID, "musket"), Items.MUSKET);
Registry.register(Registry.ITEM, new ResourceLocation(MODID, "musket_with_bayonet"), Items.MUSKET_WITH_BAYONET);
Registry.register(Registry.ITEM, new ResourceLocation(MODID, "pistol"), Items.PISTOL);
Registry.register(Registry.ITEM, new ResourceLocation(MODID, "cartridge"), Items.CARTRIDGE);
Registry.register(BuiltInRegistries.ITEM, new ResourceLocation(MODID, "musket"), Items.MUSKET);
Registry.register(BuiltInRegistries.ITEM, new ResourceLocation(MODID, "musket_with_bayonet"), Items.MUSKET_WITH_BAYONET);
Registry.register(BuiltInRegistries.ITEM, new ResourceLocation(MODID, "pistol"), Items.PISTOL);
Registry.register(BuiltInRegistries.ITEM, new ResourceLocation(MODID, "cartridge"), Items.CARTRIDGE);

Registry.register(Registry.ENTITY_TYPE, new ResourceLocation(MODID, "bullet"), BULLET_ENTITY_TYPE);
ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.COMBAT).register(entries -> {
entries.accept(Items.MUSKET);
entries.accept(Items.MUSKET_WITH_BAYONET);
entries.accept(Items.PISTOL);
entries.accept(Items.CARTRIDGE);
});

Registry.register(BuiltInRegistries.ENTITY_TYPE, new ResourceLocation(MODID, "bullet"), BULLET_ENTITY_TYPE);

Registry.register(Registry.SOUND_EVENT, Sounds.MUSKET_LOAD_0.getLocation(), Sounds.MUSKET_LOAD_0);
Registry.register(Registry.SOUND_EVENT, Sounds.MUSKET_LOAD_1.getLocation(), Sounds.MUSKET_LOAD_1);
Registry.register(Registry.SOUND_EVENT, Sounds.MUSKET_LOAD_2.getLocation(), Sounds.MUSKET_LOAD_2);
Registry.register(Registry.SOUND_EVENT, Sounds.MUSKET_READY.getLocation(), Sounds.MUSKET_READY);
Registry.register(Registry.SOUND_EVENT, Sounds.MUSKET_FIRE.getLocation(), Sounds.MUSKET_FIRE);
Registry.register(Registry.SOUND_EVENT, Sounds.PISTOL_FIRE.getLocation(), Sounds.PISTOL_FIRE);
Registry.register(BuiltInRegistries.SOUND_EVENT, Sounds.MUSKET_LOAD_0.getLocation(), Sounds.MUSKET_LOAD_0);
Registry.register(BuiltInRegistries.SOUND_EVENT, Sounds.MUSKET_LOAD_1.getLocation(), Sounds.MUSKET_LOAD_1);
Registry.register(BuiltInRegistries.SOUND_EVENT, Sounds.MUSKET_LOAD_2.getLocation(), Sounds.MUSKET_LOAD_2);
Registry.register(BuiltInRegistries.SOUND_EVENT, Sounds.MUSKET_READY.getLocation(), Sounds.MUSKET_READY);
Registry.register(BuiltInRegistries.SOUND_EVENT, Sounds.MUSKET_FIRE.getLocation(), Sounds.MUSKET_FIRE);
Registry.register(BuiltInRegistries.SOUND_EVENT, Sounds.PISTOL_FIRE.getLocation(), Sounds.PISTOL_FIRE);

ResourceManagerHelper.get(PackType.SERVER_DATA).registerReloadListener(new IdentifiableResourceReloadListener() {
@Override
Expand Down
8 changes: 4 additions & 4 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"musketmod.mixins.json"
],
"depends": {
"minecraft": "~1.19",
"java": ">=17",
"fabricloader": ">=0.14.9",
"fabric": "*"
"fabricloader": ">=0.14.11",
"fabric-api": "*",
"minecraft": "~1.19.3",
"java": ">=17"
}
}
17 changes: 5 additions & 12 deletions forge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
}
plugins {
id 'eclipse'
id 'net.minecraftforge.gradle' version '5.1.+'
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'

file("../gradle.properties").withInputStream {
def props = new Properties()
props.load(it)
props.each { prop -> project.ext.set(prop.key, prop.value) }
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

version = mod_version
group = maven_group
archivesBaseName = "${mod_name}-${minecraft_version}-forge"

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

eclipse {
project { name = "${mod_name}-${minecraft_version}-forge" }
}
Expand Down
2 changes: 1 addition & 1 deletion forge/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 6 additions & 0 deletions forge/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven { url = 'https://maven.minecraftforge.net/' }
}
}
12 changes: 12 additions & 0 deletions forge/src/main/java/ewewukek/musketmod/MusketMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.event.AddReloadListenerEvent;
import net.minecraftforge.event.CreativeModeTabEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.Mod;
Expand Down Expand Up @@ -78,6 +80,16 @@ public static void onRegisterEvent(final RegisterEvent event) {
helper.register(Sounds.PISTOL_FIRE.getLocation(), Sounds.PISTOL_FIRE);
});
}

@SubscribeEvent
public static void buildContents(CreativeModeTabEvent.BuildContents event) {
if (event.getTab() == CreativeModeTabs.COMBAT) {
event.accept(Items.MUSKET);
event.accept(Items.MUSKET_WITH_BAYONET);
event.accept(Items.PISTOL);
event.accept(Items.CARTRIDGE);
}
}
}

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE)
Expand Down
2 changes: 1 addition & 1 deletion forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modLoader="javafml"
loaderVersion="[43,)"
loaderVersion="[44,)"
license="MIT License"
issueTrackerURL="https://github.com/ewewukek/mc-musketmod/issues"
[[mods]]
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ mod_name=musketmod
mod_version=1.4.6
maven_group=ewewukek.musketmod

minecraft_version=1.19.2
minecraft_version=1.19.3

forge_version=43.1.1
forge_version=44.1.0

fabric_loader_version=0.14.9
fabric_version=0.62.0+1.19.2
fabric_loader_version=0.14.11
fabric_version=0.68.1+1.19.3
3 changes: 2 additions & 1 deletion src/main/java/ewewukek/musketmod/BulletEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
Expand Down Expand Up @@ -278,7 +279,7 @@ public void addAdditionalSaveData(CompoundTag compound) {

// workaround for ClientboundAddEntityPacket.LIMIT
@Override
public Packet<?> getAddEntityPacket() {
public Packet<ClientGamePacketListener> getAddEntityPacket() {
Entity owner = getOwner();
return new ClientboundAddEntityPacket(
getId(), getUUID(),
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/ewewukek/musketmod/BulletRenderer.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package ewewukek.musketmod;

import org.joml.Matrix3f;
import org.joml.Matrix4f;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Matrix3f;
import com.mojang.math.Matrix4f;
import com.mojang.math.Vector3f;
import com.mojang.math.Axis;

import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
Expand Down Expand Up @@ -34,7 +35,7 @@ public void render(BulletEntity bullet, float yaw, float partialTicks, PoseStack
matrixStack.scale(0.1f, 0.1f, 0.1f);
// billboarding
matrixStack.mulPose(entityRenderDispatcher.cameraOrientation());
matrixStack.mulPose(Vector3f.YP.rotationDegrees(180));
matrixStack.mulPose(Axis.YP.rotationDegrees(180));

PoseStack.Pose entry = matrixStack.last();
Matrix4f positionMatrix = entry.pose();
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/ewewukek/musketmod/ClientUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Optional;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import com.mojang.math.Axis;

import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.AbstractClientPlayer;
Expand Down Expand Up @@ -40,7 +40,7 @@ public static void renderGunInHand(ItemInHandRenderer renderer, AbstractClientPl
if (!gunItem.canUseFrom(player, hand)) {
matrixStack.pushPose();
matrixStack.translate(sign * 0.5, -0.5 - 0.6 * equipProgress, -0.7);
matrixStack.mulPose(Vector3f.XP.rotationDegrees(70));
matrixStack.mulPose(Axis.XP.rotationDegrees(70));
renderer.renderItem(player, stack, isRightHand ? ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND : ItemTransforms.TransformType.FIRST_PERSON_LEFT_HAND, !isRightHand, matrixStack, render, packedLight);
matrixStack.popPose();
return;
Expand All @@ -59,18 +59,18 @@ public static void renderGunInHand(ItemInHandRenderer renderer, AbstractClientPl

if (gunItem == Items.MUSKET_WITH_BAYONET) {
matrixStack.translate(sign * -0.05 * swingNormal, 0, 0.05 - 0.3 * swingSharp);
matrixStack.mulPose(Vector3f.YP.rotationDegrees(5 * swingSharp));
matrixStack.mulPose(Axis.YP.rotationDegrees(5 * swingSharp));
} else {
matrixStack.translate(sign * 0.05 * (1 - swingNormal), 0.05 * (1 - swingNormal), 0.05 - 0.4 * swingSharp);
matrixStack.mulPose(Vector3f.XP.rotationDegrees(180 + sign * 20 * (1 - swingSharp)));
matrixStack.mulPose(Axis.XP.rotationDegrees(180 + sign * 20 * (1 - swingSharp)));
}

} else if (player.isUsingItem() && player.getUsedItemHand() == hand) {
float usingDuration = stack.getUseDuration() - (player.getUseItemRemainingTicks() - partialTicks + 1);
if (usingDuration > 0 && usingDuration < GunItem.RELOAD_DURATION) {
matrixStack.translate(0, -0.3, 0.05);
matrixStack.mulPose(Vector3f.XP.rotationDegrees(60));
matrixStack.mulPose(Vector3f.ZP.rotationDegrees(10));
matrixStack.mulPose(Axis.XP.rotationDegrees(60));
matrixStack.mulPose(Axis.ZP.rotationDegrees(10));

if (usingDuration >= 8 && usingDuration <= 14 || usingDuration >= 18 && usingDuration <= 24) {
if (usingDuration >= 18) usingDuration -= 10;
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/ewewukek/musketmod/Items.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package ewewukek.musketmod;

import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;

public class Items {
public static final Item CARTRIDGE = new Item(new Item.Properties().tab(CreativeModeTab.TAB_COMBAT));
public static final Item MUSKET = new MusketItem(new Item.Properties().tab(CreativeModeTab.TAB_COMBAT), false);
public static final Item MUSKET_WITH_BAYONET = new MusketItem(new Item.Properties().tab(CreativeModeTab.TAB_COMBAT), true);
public static final Item PISTOL = new PistolItem(new Item.Properties().tab(CreativeModeTab.TAB_COMBAT));
public static final Item CARTRIDGE = new Item(new Item.Properties());
public static final Item MUSKET = new MusketItem(new Item.Properties(), false);
public static final Item MUSKET_WITH_BAYONET = new MusketItem(new Item.Properties(), true);
public static final Item PISTOL = new PistolItem(new Item.Properties());
}
12 changes: 6 additions & 6 deletions src/main/java/ewewukek/musketmod/Sounds.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import net.minecraft.sounds.SoundEvent;

public class Sounds {
public static final SoundEvent MUSKET_LOAD_0 = new SoundEvent(new ResourceLocation(MusketMod.MODID, "musket_load0"));
public static final SoundEvent MUSKET_LOAD_1 = new SoundEvent(new ResourceLocation(MusketMod.MODID, "musket_load1"));
public static final SoundEvent MUSKET_LOAD_2 = new SoundEvent(new ResourceLocation(MusketMod.MODID, "musket_load2"));
public static final SoundEvent MUSKET_READY = new SoundEvent(new ResourceLocation(MusketMod.MODID, "musket_ready"));
public static final SoundEvent MUSKET_FIRE = new SoundEvent(new ResourceLocation(MusketMod.MODID, "musket_fire"));
public static final SoundEvent PISTOL_FIRE = new SoundEvent(new ResourceLocation(MusketMod.MODID, "pistol_fire"));
public static final SoundEvent MUSKET_LOAD_0 = SoundEvent.createVariableRangeEvent(new ResourceLocation(MusketMod.MODID, "musket_load0"));
public static final SoundEvent MUSKET_LOAD_1 = SoundEvent.createVariableRangeEvent(new ResourceLocation(MusketMod.MODID, "musket_load1"));
public static final SoundEvent MUSKET_LOAD_2 = SoundEvent.createVariableRangeEvent(new ResourceLocation(MusketMod.MODID, "musket_load2"));
public static final SoundEvent MUSKET_READY = SoundEvent.createVariableRangeEvent(new ResourceLocation(MusketMod.MODID, "musket_ready"));
public static final SoundEvent MUSKET_FIRE = SoundEvent.createVariableRangeEvent(new ResourceLocation(MusketMod.MODID, "musket_fire"));
public static final SoundEvent PISTOL_FIRE = SoundEvent.createVariableRangeEvent(new ResourceLocation(MusketMod.MODID, "pistol_fire"));
}
4 changes: 3 additions & 1 deletion src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"pack": {
"description": "musketmod resources",
"pack_format": 9
"pack_format": 12,
"forge:resource_pack_format": 12,
"forge:data_pack_format": 10
}
}

0 comments on commit 803f544

Please sign in to comment.