Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Create 1.18.2/feature/scripting with some code" #3

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ Changelog
First Ogden version! Keep in mind that many things are still in development.
- Added default bullets that can be illuminated and adapted to multiple ammunition types
- Added ammunition configuration
- Added firearm ammunition configuration
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ More to come...

- Firearm data packing
- Firearm action script
- Key handling
- Boilerplate
- Start of action
- End of action
- NBT modification
- NBT querying
- Functions
- Firearm action properties
- Firearm action properties
- Boilerplate
- Firearm damage properties
- Boilerplate
Expand All @@ -41,7 +40,3 @@ More to come...

- Damage mods compat
- First Aid


- Documentation for content creation

192 changes: 0 additions & 192 deletions Scripting-Documentation.md

This file was deleted.

2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pluginManagement {
}

plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
}

rootProject.name = 'Ogden'
14 changes: 0 additions & 14 deletions src/main/java/rbasamoyai/ogden/OgdenClient.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package rbasamoyai.ogden;

import net.minecraft.client.Minecraft;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import rbasamoyai.ogden.entities.OgdenBulletRenderer;
import rbasamoyai.ogden.index.OgdenEntityTypes;
Expand All @@ -13,20 +9,10 @@ public class OgdenClient {

public static void init(IEventBus modBus, IEventBus forgeBus) {
modBus.addListener(OgdenClient::setupRenderers);

forgeBus.addListener(OgdenClient::onInput);
}

public static void setupRenderers(final EntityRenderersEvent.RegisterRenderers evt) {
evt.registerEntityRenderer(OgdenEntityTypes.BULLET.get(), OgdenBulletRenderer::new);
}

public static void onInput(final InputEvent evt) {
Minecraft mc = Minecraft.getInstance();
if (mc.player == null) return;

ItemStack stack = mc.player.getUseItem();
InteractionHand hand = mc.player.getUsedItemHand();
}

}
68 changes: 1 addition & 67 deletions src/main/java/rbasamoyai/ogden/OgdenMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,24 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.LevelAccessor;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.AddReloadListenerEvent;
import net.minecraftforge.event.OnDatapackSyncEvent;
import net.minecraftforge.event.entity.living.LivingGetProjectileEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.config.ModConfigEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.NewRegistryEvent;
import rbasamoyai.ogden.ammunition.AmmunitionPropertiesHandler;
import rbasamoyai.ogden.ammunition.clips.ClipPropertiesHandler;
import rbasamoyai.ogden.firearms.OgdenFirearmItem;
import rbasamoyai.ogden.firearms.config.FirearmAcceptedAmmunitionHandler;
import rbasamoyai.ogden.firearms.config.FirearmAmmoPredicate;
import rbasamoyai.ogden.firearms.scripting.FirearmScriptHandler;
import rbasamoyai.ogden.index.OgdenAmmoGroup;
import rbasamoyai.ogden.index.OgdenBaseGroup;
import rbasamoyai.ogden.index.OgdenEntityTypes;
import rbasamoyai.ogden.index.OgdenFirearmsGroup;
import rbasamoyai.ogden.index.OgdenItems;
import rbasamoyai.ogden.index.OgdenProjectilePropertiesRegistry;
import rbasamoyai.ogden.index.OgdenRegistries;
import rbasamoyai.ogden.index.OgdenScriptInstructionTypes;
import rbasamoyai.ogden.network.OgdenNetwork;

@Mod(OgdenMod.MOD_ID)
Expand All @@ -57,15 +42,12 @@ public OgdenMod() {
IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
IEventBus forgeBus = MinecraftForge.EVENT_BUS;

modBus.addListener(this::onNewRegistry);
modBus.addListener(this::commonSetup);
modBus.addListener(this::onLoadConfig);
modBus.addListener(this::onReloadConfig);

forgeBus.addListener(this::registerResourceListeners);
forgeBus.addListener(this::onDatapackSync);
forgeBus.addListener(this::onLoadLevel);
forgeBus.addListener(this::getProjectileItem);

OgdenConfigs.registerConfigs();

Expand All @@ -75,12 +57,6 @@ public OgdenMod() {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> OgdenClient.init(modBus, forgeBus));
}

private void onNewRegistry(final NewRegistryEvent evt) {
OgdenRegistries.initRegistries();

OgdenScriptInstructionTypes.register();
}

private void commonSetup(final FMLCommonSetupEvent evt) {
evt.enqueueWork(() -> {
OgdenNetwork.init();
Expand All @@ -90,36 +66,15 @@ private void commonSetup(final FMLCommonSetupEvent evt) {

private void registerResourceListeners(final AddReloadListenerEvent evt) {
evt.addListener(AmmunitionPropertiesHandler.ReloadListener.INSTANCE);
evt.addListener(ClipPropertiesHandler.AcceptedAmmoReloadListener.INSTANCE);
evt.addListener(ClipPropertiesHandler.CapacityReloadListener.INSTANCE);
evt.addListener(FirearmAcceptedAmmunitionHandler.ReloadListener.INSTANCE);
evt.addListener(FirearmScriptHandler.ReloadListener.INSTANCE);}

public void loadTags() {
ClipPropertiesHandler.loadTags();
FirearmAcceptedAmmunitionHandler.loadTags();
}

public void onDatapackSync(final OnDatapackSyncEvent evt) {
if (evt.getPlayer() == null) {
this.loadTags();

MinecraftServer server = evt.getPlayerList().getServer();
AmmunitionPropertiesHandler.syncToAll(server);
ClipPropertiesHandler.syncToAll(server);
FirearmAcceptedAmmunitionHandler.syncToAll(server);
AmmunitionPropertiesHandler.syncToServer(server);
} else {
ServerPlayer player = evt.getPlayer();
AmmunitionPropertiesHandler.syncToPlayer(player);
ClipPropertiesHandler.syncToPlayer(player);
FirearmAcceptedAmmunitionHandler.syncToPlayer(player);
}
}

public void onLoadLevel(final WorldEvent.Load evt) {
LevelAccessor level = evt.getWorld();
if (level.getServer() != null && !level.isClientSide() && level.getServer().overworld() == level) {
this.loadTags();
}
}

Expand All @@ -131,27 +86,6 @@ public void onReloadConfig(final ModConfigEvent.Reloading evt) {
OgdenConfigs.onModConfigReload(evt.getConfig());
}

public void getProjectileItem(final LivingGetProjectileEvent evt) {
ItemStack shootable = evt.getProjectileWeaponItemStack();
LivingEntity entity = evt.getEntityLiving();
ItemStack projectile = evt.getProjectileItemStack();
if (shootable.getItem() instanceof OgdenFirearmItem firearm) {
FirearmAmmoPredicate predicate = firearm.getFirearmPredicate();
if (predicate.test(projectile))
return;
ItemStack creativeStack = predicate.getCreativeItemStack();
// TODO registry
if (entity instanceof Monster monster) {
evt.setProjectileItemStack(creativeStack);
return;
}
if (entity instanceof Player player) {
evt.setProjectileItemStack(player.isCreative() ? creativeStack : ItemStack.EMPTY);
return;
}
}
}

public static ResourceLocation resource(String path) { return new ResourceLocation(MOD_ID, path); }

}
Loading
Loading