Compare commits
4
Commits
f75568214a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d311443c2a | ||
|
|
9b7de72b87 | ||
|
|
e181af7ac8 | ||
|
|
b54023ff12 |
No files matched your search
@@ -0,0 +1,25 @@
|
||||
---
|
||||
name: Bug Report
|
||||
about: Create a report to help improve ContraptionsAreSafe
|
||||
title: '[BUG] '
|
||||
labels: bug
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Ride a contraption with mob X...
|
||||
2. Observe mob behavior...
|
||||
|
||||
**Mod Version & Environment**
|
||||
- Minecraft Version: 1.20.1
|
||||
- Forge Version:
|
||||
- Create Version:
|
||||
- Create Repair Version (if present):
|
||||
- Mod Version: 1.0.0
|
||||
|
||||
**Logs / Screenshots**
|
||||
Attach relevant `debug.log` or crash reports if available.
|
||||
@@ -23,3 +23,4 @@ run
|
||||
|
||||
# Files from Forge MDK
|
||||
forge*changelog.txt
|
||||
/run-data/
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
Minecraft Forge: Credits/Thank You
|
||||
|
||||
Forge is a set of tools and modifications to the Minecraft base game code to assist
|
||||
mod developers in creating new and exciting content. It has been in development for
|
||||
several years now, but I would like to take this time thank a few people who have
|
||||
helped it along it's way.
|
||||
|
||||
First, the people who originally created the Forge projects way back in Minecraft
|
||||
alpha. Eloraam of RedPower, and SpaceToad of Buildcraft, without their acceptiance
|
||||
of me taking over the project, who knows what Minecraft modding would be today.
|
||||
|
||||
Secondly, someone who has worked with me, and developed some of the core features
|
||||
that allow modding to be as functional, and as simple as it is, cpw. For developing
|
||||
FML, which stabelized the client and server modding ecosystem. As well as the base
|
||||
loading system that allows us to modify Minecraft's code as elegently as possible.
|
||||
|
||||
Mezz, who has stepped up as the issue and pull request manager. Helping to keep me
|
||||
sane as well as guiding the community into creating better additions to Forge.
|
||||
|
||||
Searge, Bspks, Fesh0r, ProfMobious, and all the rest over on the MCP team {of which
|
||||
I am a part}. For creating some of the core tools needed to make Minecraft modding
|
||||
both possible, and as stable as can be.
|
||||
On that note, here is some specific information of the MCP data we use:
|
||||
* Minecraft Coder Pack (MCP) *
|
||||
Forge Mod Loader and Minecraft Forge have permission to distribute and automatically
|
||||
download components of MCP and distribute MCP data files. This permission is not
|
||||
transitive and others wishing to redistribute the Minecraft Forge source independently
|
||||
should seek permission of MCP or remove the MCP data files and request their users
|
||||
to download MCP separately.
|
||||
|
||||
And lastly, the countless community members who have spent time submitting bug reports,
|
||||
pull requests, and just helping out the community in general. Thank you.
|
||||
|
||||
--LexManos
|
||||
|
||||
=========================================================================
|
||||
|
||||
This is Forge Mod Loader.
|
||||
|
||||
You can find the source code at all times at https://github.com/MinecraftForge/MinecraftForge/tree/1.12.x/src/main/java/net/minecraftforge/fml
|
||||
|
||||
This minecraft mod is a clean open source implementation of a mod loader for minecraft servers
|
||||
and minecraft clients.
|
||||
|
||||
The code is authored by cpw.
|
||||
|
||||
It began by partially implementing an API defined by the client side ModLoader, authored by Risugami.
|
||||
http://www.minecraftforum.net/topic/75440-
|
||||
This support has been dropped as of Minecraft release 1.7, as Risugami no longer maintains ModLoader.
|
||||
|
||||
It also contains suggestions and hints and generous helpings of code from LexManos, author of MinecraftForge.
|
||||
http://www.minecraftforge.net/
|
||||
|
||||
Additionally, it contains an implementation of topological sort based on that
|
||||
published at http://keithschwarz.com/interesting/code/?dir=topological-sort
|
||||
|
||||
It also contains code from the Maven project for performing versioned dependency
|
||||
resolution. http://maven.apache.org/
|
||||
|
||||
It also contains a partial repackaging of the javaxdelta library from http://sourceforge.net/projects/javaxdelta/
|
||||
with credit to it's authors.
|
||||
|
||||
Forge Mod Loader downloads components from the Minecraft Coder Pack
|
||||
(http://mcp.ocean-labs.de/index.php/Main_Page) with kind permission from the MCP team.
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
# Contraptions Are Safe
|
||||
[](https://github.com/BipolarExpedition/ContraptionsAreSafe/blob/main/LICENSE)
|
||||

|
||||
[](https://github.com/BipolarExpedition/ContraptionsAreSafe/releases)
|
||||
|
||||
[](https://www.curseforge.com/minecraft/mc-mods/contraptions-are-safe)
|
||||
|
||||
----
|
||||
|
||||
"[Contraptions Are Safe](https://github.com/BipolarExpedition/ContraptionsAreSafe)" attempts to keep riders of Create contraptions safe.
|
||||
It does this using a mixin for the TargetingConditions.test method, inserting a check if the target is riding a contraption.
|
||||
|
||||
## Important Details
|
||||
|
||||
- Currently, this mod is only available for Forge 1.20.1. There is an existing mod that covers 1.21.1.
|
||||
- This mod attempts to protect riders from the initial targeting only, and mobs will usually continue to track players after they mount a contraption.
|
||||
Depending on the other mods being used, the mob may follow without attacking, or it may attack the player.
|
||||
- Mobs from some mods use a different method for targeting and attacking players. The Mur Mur mob from Alex's Mobs is an example of a very aggressive and persistent mob that is not protected against.
|
||||
- In testing in vanilla, being spotted/targeted by a mob before mounting the contraption usually resulted in the mob following you but not attacking. An exception was a creeper that started the detonation sequence would finish the process and explode, even after the user mounted the contraption.
|
||||
- When testing in the huge mod pack Linggango, being seen before mounting the contraption resulted in the mob tracking you down and, in most cases, still attacking you. If you are on the contraption before it can see you, you will be effectively invisible to them. Keep in mind that some mobs can see you at extreme ranges.
|
||||
- Before release, I decided to expand the protections beyond players, to prevent mobs acting as conductors from being attacked.
|
||||
|
||||
## Future Ideas
|
||||
|
||||
- Excluding players on vehicles and seats from being included in calculation of sleeping players percent
|
||||
- Adding protection for players on elevators without using seats.
|
||||
|
||||
## Additional Info
|
||||
|
||||
While I may have edited existing mods for private use by my friends and I, this is the first Minecraft mod I have made.
|
||||
I hope people find it useful and of sufficient quality.
|
||||
I look forward to learning more about modding ([Basics](https://www.youtube.com/playlist?list=PLKGarocXCE1Egp6soRNlflWJWc44sau40) and [Forge Specifically](https://www.youtube.com/playlist?list=PLKGarocXCE1H9Y21-pxjt5Pt8bW14twa-)) and implementing ideas I've had for years.
|
||||
|
||||
## Versions
|
||||
|
||||
- 1.0.0 - First release. Protecting riders of Create contraptions.
|
||||
|
||||
## URLs
|
||||
- [Source Repository](https://github.com/BipolarExpedition/ContraptionsAreSafe)
|
||||
- [Issues Reporting](https://github.com/BipolarExpedition/ContraptionsAreSafe/issues)
|
||||
- [Curseforge](https://www.curseforge.com/minecraft/mc-mods/contraptions-are-safe)
|
||||
- Modrinth (Not yet released)
|
||||
|
||||
## License
|
||||
[MIT](https://opensource.org/license/mit)
|
||||
|
||||
## Disclaimer
|
||||
|
||||
"Robo-Reddit" (Gemini Chat LLM) was used to brainstorm, debug, and learn a crash course in minecraft modding, using the example template from the Forge MDK.
|
||||
While it presented examples, AI was not used to generate this source code.
|
||||
|
||||
Note, most of its suggested code and suggested fixes for bugs were incorrect or inefficient. It served more of a method for exploring ideas.
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
|
||||
Source installation information for modders
|
||||
-------------------------------------------
|
||||
This code follows the Minecraft Forge installation methodology. It will apply
|
||||
some small patches to the vanilla MCP source code, giving you and it access
|
||||
to some of the data and functions you need to build a successful mod.
|
||||
|
||||
Note also that the patches are built against "un-renamed" MCP source code (aka
|
||||
SRG Names) - this means that you will not be able to read them directly against
|
||||
normal code.
|
||||
|
||||
Setup Process:
|
||||
==============================
|
||||
|
||||
Step 1: Open your command-line and browse to the folder where you extracted the zip file.
|
||||
|
||||
Step 2: You're left with a choice.
|
||||
If you prefer to use Eclipse:
|
||||
1. Run the following command: `./gradlew genEclipseRuns`
|
||||
2. Open Eclipse, Import > Existing Gradle Project > Select Folder
|
||||
or run `gradlew eclipse` to generate the project.
|
||||
|
||||
If you prefer to use IntelliJ:
|
||||
1. Open IDEA, and import project.
|
||||
2. Select your build.gradle file and have it import.
|
||||
3. Run the following command: `./gradlew genIntellijRuns`
|
||||
4. Refresh the Gradle Project in IDEA if required.
|
||||
|
||||
If at any point you are missing libraries in your IDE, or you've run into problems you can
|
||||
run `gradlew --refresh-dependencies` to refresh the local cache. `gradlew clean` to reset everything
|
||||
(this does not affect your code) and then start the process again.
|
||||
|
||||
Mapping Names:
|
||||
=============================
|
||||
By default, the MDK is configured to use the official mapping names from Mojang for methods and fields
|
||||
in the Minecraft codebase. These names are covered by a specific license. All modders should be aware of this
|
||||
license, if you do not agree with it you can change your mapping names to other crowdsourced names in your
|
||||
build.gradle. For the latest license text, refer to the mapping file itself, or the reference copy here:
|
||||
https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
|
||||
|
||||
Additional Resources:
|
||||
=========================
|
||||
Community Documentation: https://docs.minecraftforge.net/en/1.20.1/gettingstarted/
|
||||
LexManos' Install Video: https://youtu.be/8VEdtQLuLO0
|
||||
Forge Forums: https://forums.minecraftforge.net/
|
||||
Forge Discord: https://discord.minecraftforge.net/
|
||||
+12
-1072
File diff suppressed because it is too large.
Load diff
+2
-2
@@ -48,7 +48,7 @@ mod_name=ContraptionsAreSafe
|
||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=MIT
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=0.1.0
|
||||
mod_version=1.0.0
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
@@ -56,7 +56,7 @@ mod_group_id=com.bipolarexpedition.java.contraptions_are_safe
|
||||
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
|
||||
mod_authors=BipolarExpedition
|
||||
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
||||
mod_description=Example mod description.\nNewline characters can be used and will be replaced properly.
|
||||
mod_description=Protects players riding contraptions. \nEnsures players seated/riding on a contraption can not be targeted by mobs in most cases.
|
||||
|
||||
create_version = 6.0.8-289
|
||||
ponder_version = 1.0.91
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package com.bipolarexpedition.java.contraptions_are_safe;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
//import net.minecraft.resources.ResourceLocation;
|
||||
//import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
//import net.minecraftforge.registries.ForgeRegistries;
|
||||
//
|
||||
//import java.util.Collections;
|
||||
//import java.util.List;
|
||||
//import java.util.Set;
|
||||
//import java.util.stream.Collectors;
|
||||
|
||||
// An example config class. This is not required, but it's a good idea to have one to keep your config organized.
|
||||
// Demonstrates how to use Forge's config APIs
|
||||
@@ -19,46 +19,30 @@ import java.util.stream.Collectors;
|
||||
public class Config
|
||||
{
|
||||
private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
|
||||
|
||||
private static final ForgeConfigSpec.BooleanValue LOG_DIRT_BLOCK = BUILDER
|
||||
.comment("Whether to log the dirt block on common setup")
|
||||
.define("logDirtBlock", true);
|
||||
|
||||
private static final ForgeConfigSpec.IntValue MAGIC_NUMBER = BUILDER
|
||||
.comment("A magic number")
|
||||
.defineInRange("magicNumber", 42, 0, Integer.MAX_VALUE);
|
||||
|
||||
public static final ForgeConfigSpec.ConfigValue<String> MAGIC_NUMBER_INTRODUCTION = BUILDER
|
||||
.comment("What you want the introduction message to be for the magic number")
|
||||
.define("magicNumberIntroduction", "The magic number is... ");
|
||||
|
||||
// a list of strings that are treated as resource locations for items
|
||||
private static final ForgeConfigSpec.ConfigValue<List<? extends String>> ITEM_STRINGS = BUILDER
|
||||
.comment("A list of items to log on common setup.")
|
||||
.defineListAllowEmpty("items", List.of("minecraft:iron_ingot"), Config::validateItemName);
|
||||
//
|
||||
// private static final ForgeConfigSpec.BooleanValue LOG_DIRT_BLOCK = BUILDER
|
||||
// .comment("Whether to log the dirt block on common setup")
|
||||
// .define("logDirtBlock", true);
|
||||
//
|
||||
// private static final ForgeConfigSpec.IntValue MAGIC_NUMBER = BUILDER
|
||||
// .comment("A magic number")
|
||||
// .defineInRange("magicNumber", 42, 0, Integer.MAX_VALUE);
|
||||
//
|
||||
// public static final ForgeConfigSpec.ConfigValue<String> MAGIC_NUMBER_INTRODUCTION = BUILDER
|
||||
// .comment("What you want the introduction message to be for the magic number")
|
||||
// .define("magicNumberIntroduction", "The magic number is... ");
|
||||
|
||||
static final ForgeConfigSpec SPEC = BUILDER.build();
|
||||
|
||||
public static boolean logDirtBlock;
|
||||
public static int magicNumber;
|
||||
public static String magicNumberIntroduction;
|
||||
public static Set<Item> items;
|
||||
|
||||
private static boolean validateItemName(final Object obj)
|
||||
{
|
||||
return obj instanceof final String itemName && ForgeRegistries.ITEMS.containsKey(new ResourceLocation(itemName));
|
||||
}
|
||||
// public static boolean logDirtBlock;
|
||||
// public static int magicNumber;
|
||||
// public static String magicNumberIntroduction;
|
||||
|
||||
@SubscribeEvent
|
||||
static void onLoad(final ModConfigEvent event)
|
||||
{
|
||||
logDirtBlock = LOG_DIRT_BLOCK.get();
|
||||
magicNumber = MAGIC_NUMBER.get();
|
||||
magicNumberIntroduction = MAGIC_NUMBER_INTRODUCTION.get();
|
||||
|
||||
// convert the list of strings into a set of items
|
||||
items = ITEM_STRINGS.get().stream()
|
||||
.map(itemName -> ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemName)))
|
||||
.collect(Collectors.toSet());
|
||||
// logDirtBlock = LOG_DIRT_BLOCK.get();
|
||||
// magicNumber = MAGIC_NUMBER.get();
|
||||
// magicNumberIntroduction = MAGIC_NUMBER_INTRODUCTION.get();
|
||||
}
|
||||
}
|
||||
+19
-78
@@ -1,31 +1,31 @@
|
||||
package com.bipolarexpedition.java.contraptions_are_safe;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
//import net.minecraft.client.Minecraft;
|
||||
//import net.minecraft.core.registries.Registries;
|
||||
//import net.minecraft.world.food.FoodProperties;
|
||||
//import net.minecraft.world.item.BlockItem;
|
||||
//import net.minecraft.world.item.CreativeModeTab;
|
||||
//import net.minecraft.world.item.CreativeModeTabs;
|
||||
//import net.minecraft.world.item.Item;
|
||||
//import net.minecraft.world.level.block.Block;
|
||||
//import net.minecraft.world.level.block.Blocks;
|
||||
//import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
//import net.minecraft.world.level.material.MapColor;
|
||||
//import net.minecraftforge.api.distmarker.Dist;
|
||||
//import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.event.server.ServerStartingEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
//import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
//import net.minecraftforge.registries.DeferredRegister;
|
||||
//import net.minecraftforge.registries.ForgeRegistries;
|
||||
//import net.minecraftforge.registries.RegistryObject;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
// The value here should match an entry in the META-INF/mods.toml file
|
||||
@@ -37,28 +37,6 @@ public class ContraptionsAreSafe
|
||||
// Directly reference a slf4j logger
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
// Create a Deferred Register to hold Blocks which will all be registered under the "contraptions_are_safe" namespace
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
// Create a Deferred Register to hold Items which will all be registered under the "contraptions_are_safe" namespace
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
// Create a Deferred Register to hold CreativeModeTabs which will all be registered under the "contraptions_are_safe" namespace
|
||||
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID);
|
||||
|
||||
// Creates a new Block with the id "contraptions_are_safe:example_block", combining the namespace and path
|
||||
public static final RegistryObject<Block> EXAMPLE_BLOCK = BLOCKS.register("example_block", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
||||
// Creates a new BlockItem with the id "contraptions_are_safe:example_block", combining the namespace and path
|
||||
public static final RegistryObject<Item> EXAMPLE_BLOCK_ITEM = ITEMS.register("example_block", () -> new BlockItem(EXAMPLE_BLOCK.get(), new Item.Properties()));
|
||||
|
||||
// Creates a new food item with the id "contraptions_are_safe:example_id", nutrition 1 and saturation 2
|
||||
public static final RegistryObject<Item> EXAMPLE_ITEM = ITEMS.register("example_item", () -> new Item(new Item.Properties().food(new FoodProperties.Builder()
|
||||
.alwaysEat().nutrition(1).saturationMod(2f).build())));
|
||||
|
||||
// Creates a creative tab with the id "contraptions_are_safe:example_tab" for the example item, that is placed after the combat tab
|
||||
public static final RegistryObject<CreativeModeTab> EXAMPLE_TAB = CREATIVE_MODE_TABS.register("example_tab", () -> CreativeModeTab.builder()
|
||||
.withTabsBefore(CreativeModeTabs.COMBAT)
|
||||
.icon(() -> EXAMPLE_ITEM.get().getDefaultInstance())
|
||||
.displayItems((parameters, output) -> {
|
||||
output.accept(EXAMPLE_ITEM.get()); // Add the example item to the tab. For your own tabs, this method is preferred over the event
|
||||
}).build());
|
||||
|
||||
public ContraptionsAreSafe(FMLJavaModLoadingContext context)
|
||||
{
|
||||
@@ -67,19 +45,9 @@ public class ContraptionsAreSafe
|
||||
// Register the commonSetup method for modloading
|
||||
modEventBus.addListener(this::commonSetup);
|
||||
|
||||
// Register the Deferred Register to the mod event bus so blocks get registered
|
||||
BLOCKS.register(modEventBus);
|
||||
// Register the Deferred Register to the mod event bus so items get registered
|
||||
ITEMS.register(modEventBus);
|
||||
// Register the Deferred Register to the mod event bus so tabs get registered
|
||||
CREATIVE_MODE_TABS.register(modEventBus);
|
||||
|
||||
// Register ourselves for server and other game events we are interested in
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
// Register the item to a creative tab
|
||||
modEventBus.addListener(this::addCreative);
|
||||
|
||||
// Register our mod's ForgeConfigSpec so that Forge can create and load the config file for us
|
||||
context.registerConfig(ModConfig.Type.COMMON, Config.SPEC);
|
||||
}
|
||||
@@ -87,21 +55,7 @@ public class ContraptionsAreSafe
|
||||
private void commonSetup(final FMLCommonSetupEvent event)
|
||||
{
|
||||
// Some common setup code
|
||||
LOGGER.info("HELLO FROM COMMON SETUP");
|
||||
|
||||
if (Config.logDirtBlock)
|
||||
LOGGER.info("DIRT BLOCK >> {}", ForgeRegistries.BLOCKS.getKey(Blocks.DIRT));
|
||||
|
||||
LOGGER.info(Config.magicNumberIntroduction + Config.magicNumber);
|
||||
|
||||
Config.items.forEach((item) -> LOGGER.info("ITEM >> {}", item.toString()));
|
||||
}
|
||||
|
||||
// Add the example block item to the building blocks tab
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(EXAMPLE_BLOCK_ITEM);
|
||||
LOGGER.debug("HELLO FROM COMMON SETUP for Contraptions Are Safe");
|
||||
}
|
||||
|
||||
// You can use SubscribeEvent and let the Event Bus discover methods to call
|
||||
@@ -109,19 +63,6 @@ public class ContraptionsAreSafe
|
||||
public void onServerStarting(ServerStartingEvent event)
|
||||
{
|
||||
// Do something when the server starts
|
||||
LOGGER.info("HELLO from server starting");
|
||||
}
|
||||
|
||||
// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
|
||||
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
public static class ClientModEvents
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void onClientSetup(FMLClientSetupEvent event)
|
||||
{
|
||||
// Some client setup code
|
||||
LOGGER.info("HELLO FROM CLIENT SETUP");
|
||||
LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName());
|
||||
}
|
||||
LOGGER.debug("HELLO from Contraptions Are Safe for server starting");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.bipolarexpedition.java.contraptions_are_safe;
|
||||
|
||||
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
// 90% LLM's suggested solution to continuously logging values to chat.
|
||||
// Disabled in release versions
|
||||
|
||||
//@Mod.EventBusSubscriber(
|
||||
// modid = "contraptions_are_safe",
|
||||
// bus = Mod.EventBusSubscriber.Bus.FORGE
|
||||
//)
|
||||
public final class DebugTicker {
|
||||
private DebugTicker() {}
|
||||
// @SubscribeEvent
|
||||
// public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||
// if (event.phase != TickEvent.Phase.END) return;
|
||||
// if (!(event.player instanceof ServerPlayer player)) return;
|
||||
// if (player.tickCount % 20 != 0) return;
|
||||
//
|
||||
// player.sendSystemMessage(Component.literal(
|
||||
// "Debug: riding=" + player.isPassenger()
|
||||
// + ", vehicle=" + player.getVehicle()
|
||||
// + ", isContraption=" + isSittingContraption(player)
|
||||
// ));
|
||||
// }
|
||||
// public static boolean isSittingContraption(ServerPlayer player) {
|
||||
// Entity player_vehicle = player.getVehicle();
|
||||
//
|
||||
// return (player_vehicle instanceof AbstractContraptionEntity);
|
||||
// }
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.bipolarexpedition.java.contraptions_are_safe.mixin;
|
||||
|
||||
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ai.targeting.TargetingConditions;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(TargetingConditions.class)
|
||||
public class IgnoreContraptionRidersMixin {
|
||||
|
||||
@Inject(method = "test", at = @At("HEAD"), cancellable = true)
|
||||
private void skipRiders(LivingEntity attacker, LivingEntity target, CallbackInfoReturnable<Boolean> ci) {
|
||||
if (target.getVehicle() instanceof AbstractContraptionEntity) {
|
||||
ci.setReturnValue(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
package com.bipolarexpedition.java.contraptions_are_safe.mixin;
|
||||
|
||||
import com.bipolarexpedition.java.contraptions_are_safe.ContraptionsAreSafe;
|
||||
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Mob.class)
|
||||
public class MobTargetingMixin {
|
||||
|
||||
@Inject(method = "canAttack(Lnet/minecraft/world/entity/LivingEntity;)Z", at = @At("HEAD"), cancellable = true)
|
||||
private void preventContraptionTargeting(LivingEntity target, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (target != null && isOnContraption(target)) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isOnContraption(Entity entity) {
|
||||
Entity vehicle = entity.getVehicle();
|
||||
while (vehicle != null) {
|
||||
if (vehicle instanceof AbstractContraptionEntity) {
|
||||
return true;
|
||||
}
|
||||
vehicle = vehicle.getVehicle();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,89 +1,36 @@
|
||||
# This is an example mods.toml file. It contains the data relating to the loading mods.
|
||||
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
|
||||
# The overall format is standard TOML format, v0.5.0.
|
||||
# Note that there are a couple of TOML lists in this file.
|
||||
# Find more information on toml format here: https://github.com/toml-lang/toml
|
||||
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||
modLoader="javafml" #mandatory
|
||||
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||
loaderVersion="${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
||||
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
||||
modLoader="javafml"
|
||||
loaderVersion="${loader_version_range}"
|
||||
license="${mod_license}"
|
||||
# A URL to refer people to when problems occur with this mod
|
||||
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
|
||||
# If your mod is purely client-side and has no multiplayer functionality (be it dedicated servers or Open to LAN),
|
||||
# set this to true, and Forge will set the correct displayTest for you and skip loading your mod on dedicated servers.
|
||||
#clientSideOnly=true #optional - defaults to false if absent
|
||||
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||
[[mods]] #mandatory
|
||||
# The modid of the mod
|
||||
modId="${mod_id}" #mandatory
|
||||
# The version number of the mod
|
||||
version="${mod_version}" #mandatory
|
||||
# A display name for the mod
|
||||
displayName="${mod_name}" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/
|
||||
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
|
||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
|
||||
# A file name (in the root of the mod JAR) containing a logo for display
|
||||
#logoFile="contraptions_are_safe.png" #optional
|
||||
# A text field displayed in the mod UI
|
||||
#credits="" #optional
|
||||
# A text field displayed in the mod UI
|
||||
authors="${mod_authors}" #optional
|
||||
# Display Test controls the display for your mod in the server connection screen
|
||||
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
|
||||
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
|
||||
# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component.
|
||||
# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value.
|
||||
# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself.
|
||||
#displayTest="MATCH_VERSION" # if nothing is specified, MATCH_VERSION is the default when clientSideOnly=false, otherwise IGNORE_ALL_VERSION when clientSideOnly=true (#optional)
|
||||
issueTrackerURL="https://github.com/BipolarExpedition/ContraptionsAreSafe/issues"
|
||||
|
||||
[[mods]]
|
||||
modId="contraptions_are_safe"
|
||||
version="${mod_version}"
|
||||
displayName="${mod_name}"
|
||||
displayURL="https://github.com/BipolarExpedition/ContraptionsAreSafe"
|
||||
logoFile="icon.png"
|
||||
authors="${mod_authors}"
|
||||
displayTest = "IGNORE_SERVER_VERSION"
|
||||
mixinConfig = "contraptionsaresafe.mixins.json"
|
||||
|
||||
# Access Transformers
|
||||
# Optional, if not specified Forge will attempt to find the default META-INF/accesstransformer.cfg and silently continue if not found. May default to an empty list in a future MC.
|
||||
# If you specify AT path strings in this list, Forge will attempt to load each of them and throw errors for any that aren't found.
|
||||
# Specifying an empty list when your mod has no ATs is recommended to opt-out of the default for slightly better loading performance.
|
||||
#accessTransformers = []
|
||||
|
||||
# The description text for the mod (multi line!) (#mandatory)
|
||||
description='''${mod_description}'''
|
||||
|
||||
[[dependencies.${mod_id}]]
|
||||
[[dependencies.contraptions_are_safe]]
|
||||
modId="create"
|
||||
mandatory=true
|
||||
versionRange="[6.0.8,6.1.0)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||
[[dependencies.${mod_id}]] #optional
|
||||
# the modid of the dependency
|
||||
modId="forge" #mandatory
|
||||
# Does this dependency have to exist - if not, ordering below must be specified
|
||||
mandatory=true #mandatory
|
||||
# The version range of the dependency
|
||||
versionRange="${forge_version_range}" #mandatory
|
||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the dependency is not mandatory
|
||||
# BEFORE - This mod is loaded BEFORE the dependency
|
||||
# AFTER - This mod is loaded AFTER the dependency
|
||||
ordering="NONE"
|
||||
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
|
||||
side="BOTH"
|
||||
# Here's another dependency
|
||||
[[dependencies.${mod_id}]]
|
||||
modId="minecraft"
|
||||
[[dependencies.contraptions_are_safe]]
|
||||
modId="forge"
|
||||
mandatory=true
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange="${minecraft_version_range}"
|
||||
versionRange="${forge_version_range}"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
# Features are specific properties of the game environment, that you may want to declare you require. This example declares
|
||||
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
|
||||
# stop your mod loading on the server for example.
|
||||
#[features.${mod_id}]
|
||||
#openGLVersion="[3.2,)"
|
||||
[[dependencies.contraptions_are_safe]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="${minecraft_version_range}"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
@@ -5,8 +5,9 @@
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"refmap": "contraptionsaresafe.refmap.json",
|
||||
"mixins": [
|
||||
"MobTargetingMixin"
|
||||
"IgnoreContraptionRidersMixin"
|
||||
],
|
||||
"client": [],
|
||||
"server": []
|
||||
"server": [
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 146 KiB |
Reference in new issue
Block a user