Skip to content

Commit

Permalink
Functional multiplayer, probably
Browse files Browse the repository at this point in the history
  • Loading branch information
jamioflan committed Nov 27, 2023
1 parent fb5e25d commit 9591736
Show file tree
Hide file tree
Showing 309 changed files with 32,642 additions and 487 deletions.
7 changes: 2 additions & 5 deletions src/main/java/com/flansmod/client/FlansModClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,11 @@ public static void RenderTick(TickEvent.RenderTickEvent event)
public static void RegisterClientReloadListeners(RegisterClientReloadListenersEvent event)
{
event.registerReloadListener(MAGAZINE_ATLAS);
}
event.registerReloadListener(ANIMATIONS);

public static void RegisterClientDataReloadListeners(AddReloadListenerEvent event)
{
event.addListener(ANIMATIONS);
FlansMod.RegisterCommonReloadListeners(event::registerReloadListener);
}


// ---------------------------
// REFLECTION
// ---------------------------
Expand Down
29 changes: 15 additions & 14 deletions src/main/java/com/flansmod/common/FlansMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.mojang.logging.LogUtils;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.PreparableReloadListener;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.inventory.MenuType;
Expand Down Expand Up @@ -56,6 +57,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

@SuppressWarnings("unused")
@Mod(FlansMod.MODID)
Expand Down Expand Up @@ -305,22 +307,21 @@ private void OnRegsiterEvent(RegisterEvent event)

private void onReloadResources(AddReloadListenerEvent event)
{
event.addListener(GUNS);
event.addListener(BULLETS);
event.addListener(ATTACHMENTS);
event.addListener(PARTS);
event.addListener(WORKBENCHES);
event.addListener(MATERIALS);
event.addListener(MAGAZINES);
event.addListener(NPCS);

if(FMLEnvironment.dist == Dist.CLIENT)
RegisterClientReloadListeners(event);
if(FMLEnvironment.dist == Dist.DEDICATED_SERVER)
{
RegisterCommonReloadListeners(event::addListener);
}
}

@OnlyIn(Dist.CLIENT)
private void RegisterClientReloadListeners(AddReloadListenerEvent event)
public static void RegisterCommonReloadListeners(Consumer<PreparableReloadListener> registerFunc)
{
FlansModClient.RegisterClientDataReloadListeners(event);
registerFunc.accept(GUNS);
registerFunc.accept(BULLETS);
registerFunc.accept(ATTACHMENTS);
registerFunc.accept(PARTS);
registerFunc.accept(WORKBENCHES);
registerFunc.accept(MATERIALS);
registerFunc.accept(MAGAZINES);
registerFunc.accept(NPCS);
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/flansmod/common/actions/ActionStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ public void OnTick(Level level, GunContext gunContext)

protected void DebugLog(String string)
{
FlansMod.LOGGER.info("[" + MinecraftHelpers.GetTick() +
(IsClient ? "|Client]" : "|Server]")
+ string);
//FlansMod.LOGGER.info("[" + MinecraftHelpers.GetTick() +
// (IsClient ? "|Client]" : "|Server]")
// + string);
}

// -------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public Inventory GetAttachedInventory()
@Override
public int hashCode()
{
return HashGunOrigins(Stack) ^ Hand.hashCode() ^ Integer.hashCode(InventorySlot) ^ ShooterContext.hashCode();
return HashGunOrigins(Stack) ^ (Hand.ordinal() << 7) ^ (InventorySlot << 13) ^ ShooterContext.hashCode();
}
@Override
public boolean equals(Object other)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.flansmod.common.gunshots;

import com.flansmod.common.FlansMod;
import com.flansmod.common.actions.GunContext;
import com.flansmod.common.types.elements.ModifierDefinition;
import com.flansmod.util.MinecraftHelpers;
Expand Down Expand Up @@ -186,7 +187,13 @@ public GunContext GetOrCreateSpecificContext(int slotIndex, int contextHash)
gunsInSlot.add(context);
// If the current slot has a good context, check it is the one we are asking for before returning it
if(context.hashCode() == contextHash)
{
return context;
}
else
{
FlansMod.LOGGER.error("Context mismatch for Shooter " + this + " in slot " + slotIndex + ". Got hash " + context.hashCode() + ", but we needed " + contextHash);
}
}

// We want a specific context, not just the latest, so return invalid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Entity Owner()
@Override
public int hashCode()
{
return Objects.hash(Shooter.getId(), Shooter.level.dimension());
return Objects.hash(Shooter.getId(), Shooter.level.dimension().toString());
}
@Override
public boolean equals(Object other)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"itemSettings": {
"maxStackSize": 1,
"tags": [
"flansmod:bullet",
"flansmod:generic"
]
},
"attachmentType": "Generic",
"modifiers": [],
"mechaEffects": [],
"mechaEffectFilter": "",
"handlerOverrides": [],
"actionOverrides": [],
"reloadOverrides": [],
"modeOverride": "FullAuto",
"overrideFireMode": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"itemSettings": {
"maxStackSize": 1,
"tags": [
"flansmod:bullet",
"flansmod:generic"
]
},
"attachmentType": "Generic",
"modifiers": [],
"mechaEffects": [],
"mechaEffectFilter": "",
"handlerOverrides": [],
"actionOverrides": [],
"reloadOverrides": [],
"modeOverride": "BurstFire",
"overrideFireMode": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"itemSettings": {
"maxStackSize": 1,
"tags": [
"flansmod:bullet",
"flansmod:generic"
]
},
"attachmentType": "Generic",
"modifiers": [],
"mechaEffects": [],
"mechaEffectFilter": "",
"handlerOverrides": [],
"actionOverrides": [],
"reloadOverrides": [],
"modeOverride": "SemiAuto",
"overrideFireMode": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"itemSettings": {
"maxStackSize": 64,
"tags": [
"flansmod:bullet",
"flansmod:artillery_shell"
]
},
"roundsPerItem": 1,
"shootStats": {
"verticalRecoil": 1.0,
"horizontalRecoil": 0.0,
"spread": 1.0,
"spreadPattern": "FilledCircle",
"speed": 0.0,
"bulletCount": 1,
"spinSpeed": 360.0,
"breaksMaterials": [
"minecraft:glass"
],
"penetrationPower": 4.0,
"impact": {
"decal": "",
"damageToTarget": 1.0,
"multiplierVsPlayers": 1.0,
"multiplierVsVehicles": 100.0,
"knockback": 0.0,
"potionEffectOnTarget": "",
"splashDamage": 0.0,
"splashDamageRadius": 0.0,
"splashDamageFalloff": 1.0,
"potionEffectOnSplash": "",
"setFireToTarget": 0.0,
"fireSpreadRadius": 0.0,
"fireSpreadAmount": 0.0,
"explosionRadius": 3.0,
"hitSounds": [],
"onImpactActions": []
},
"hitscan": true,
"fuseTime": 0.0,
"gravityFactor": 1.0,
"sticky": false,
"turnRate": 0.5,
"dragInAir": 0.01,
"trailParticles": "",
"secondsBetweenTrailParticles": 0.25,
"dragInWater": 0.2,
"waterParticles": ""
},
"onShootActions": [],
"onClipEmptyActions": [],
"onReloadActions": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"itemSettings": {
"maxStackSize": 64,
"tags": [
"flansmod:bullet",
"flansmod:artillery_shell"
]
},
"roundsPerItem": 1,
"shootStats": {
"verticalRecoil": 1.0,
"horizontalRecoil": 0.0,
"spread": 1.0,
"spreadPattern": "FilledCircle",
"speed": 0.0,
"bulletCount": 1,
"spinSpeed": 360.0,
"breaksMaterials": [
"minecraft:glass"
],
"penetrationPower": 50.0,
"impact": {
"decal": "",
"damageToTarget": 1.0,
"multiplierVsPlayers": 1.0,
"multiplierVsVehicles": 100.0,
"knockback": 0.0,
"potionEffectOnTarget": "",
"splashDamage": 0.0,
"splashDamageRadius": 0.0,
"splashDamageFalloff": 1.0,
"potionEffectOnSplash": "",
"setFireToTarget": 0.0,
"fireSpreadRadius": 0.0,
"fireSpreadAmount": 0.0,
"explosionRadius": 0.0,
"hitSounds": [],
"onImpactActions": []
},
"hitscan": true,
"fuseTime": 0.0,
"gravityFactor": 1.0,
"sticky": false,
"turnRate": 0.5,
"dragInAir": 0.01,
"trailParticles": "",
"secondsBetweenTrailParticles": 0.25,
"dragInWater": 0.2,
"waterParticles": ""
},
"onShootActions": [],
"onClipEmptyActions": [],
"onReloadActions": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"itemSettings": {
"maxStackSize": 64,
"tags": [
"flansmod:bullet",
"flansmod:artillery_shell"
]
},
"roundsPerItem": 1,
"shootStats": {
"verticalRecoil": 1.0,
"horizontalRecoil": 0.0,
"spread": 1.0,
"spreadPattern": "FilledCircle",
"speed": 0.0,
"bulletCount": 1,
"spinSpeed": 360.0,
"breaksMaterials": [],
"penetrationPower": 0.0,
"impact": {
"decal": "",
"damageToTarget": 1.0,
"multiplierVsPlayers": 1.0,
"multiplierVsVehicles": 200.0,
"knockback": 1.0,
"potionEffectOnTarget": "",
"splashDamage": 0.0,
"splashDamageRadius": 6.0,
"splashDamageFalloff": 1.0,
"potionEffectOnSplash": "",
"setFireToTarget": 0.0,
"fireSpreadRadius": 0.0,
"fireSpreadAmount": 0.0,
"explosionRadius": 5.5,
"hitSounds": [],
"onImpactActions": []
},
"hitscan": true,
"fuseTime": 0.0,
"gravityFactor": 1.0,
"sticky": false,
"turnRate": 0.5,
"dragInAir": 0.01,
"trailParticles": "",
"secondsBetweenTrailParticles": 0.25,
"dragInWater": 0.2,
"waterParticles": ""
},
"onShootActions": [],
"onClipEmptyActions": [],
"onReloadActions": []
}
Loading

0 comments on commit 9591736

Please sign in to comment.