dispenser behaviour (for arrows), allow 1.20.2, repulsive tnt recipe, fix config

This commit is contained in:
Jenny 2025-02-11 06:50:42 +01:00
parent 257553d374
commit 4959e3e0fa
Signed by: Jenny
GPG Key ID: 2072A14E40940632
7 changed files with 60 additions and 15 deletions

View File

@ -5,7 +5,7 @@ minecraft_version=1.20.1
# The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.20.1]
minecraft_version_range=[1.20.1,1.20.2]
# The Forge version must agree with the Minecraft version to get a valid artifact
forge_version=47.3.22
# The Forge version range can use any version of Forge as bounds or match the loader version range
@ -38,7 +38,7 @@ mod_name=Enhanced Explosives
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=All Rights Reserved
# The mod version. See https://semver.org/
mod_version=0.11.0
mod_version=0.12.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

View File

@ -40,10 +40,12 @@ public class EnhancedExplosives {
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ConfigClient.SPEC, "EnhancedExplosives-client.toml");
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ConfigCommon.SPEC, "EnhancedExplosives-common.toml");
}
private void commonSetup(final FMLCommonSetupEvent event) {
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ConfigCommon.SPEC);
items.registerDispenser();
}
// You can use SubscribeEvent and let the Event Bus discover methods to call

View File

@ -19,7 +19,7 @@ import static com.jenny.enhancedexplosives.EnhancedExplosives.MODID;
public class creativeTab {
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID);
public static final RegistryObject<CreativeModeTab> CREATIVE_TAB = CREATIVE_MODE_TABS.register("enhancedexplosives", () -> CreativeModeTab.builder().withTabsBefore(CreativeModeTabs.COMBAT).icon(() -> blocks.TNT_8_ITEM.get().getDefaultInstance()).displayItems((parameters, output) -> {
public static final RegistryObject<CreativeModeTab> CREATIVE_TAB = CREATIVE_MODE_TABS.register("enhancedexplosives", () -> CreativeModeTab.builder().withTabsBefore(CreativeModeTabs.SPAWN_EGGS).icon(() -> blocks.TNT_8_ITEM.get().getDefaultInstance()).displayItems((parameters, output) -> {
output.acceptAll(Arrays.stream(getBlocks()).toList());
output.acceptAll(Arrays.stream(getItems()).toList());
}).title(Component.literal("Enhanced Explosives")).build());

View File

@ -23,20 +23,20 @@ public abstract class basePrimedTNT extends Entity implements TraceableEntity {
private LivingEntity owner;
private int fuse = 0;
public basePrimedTNT(EntityType<? extends basePrimedTNT> pEntityType, Level pLevel, @Nullable LivingEntity owner) {
public basePrimedTNT(EntityType<? extends basePrimedTNT> pEntityType, @NotNull Level pLevel, @Nullable LivingEntity owner) {
super(pEntityType, pLevel);
commonInit(pLevel, owner);
this.fuse = getFuse();
}
private void commonInit(Level pLevel, @Nullable LivingEntity owner) {
private void commonInit(@NotNull Level pLevel, @Nullable LivingEntity owner) {
double d0 = pLevel.random.nextDouble() * (double)((float)Math.PI * 2F);
this.setDeltaMovement(-Math.sin(d0) * 0.02D, (double)0.2F, -Math.cos(d0) * 0.02D);
this.blocksBuilding = true;
this.owner = owner;
this.setOwner(owner);
}
public basePrimedTNT(EntityType<? extends basePrimedTNT> pEntityType, Level pLevel, @Nullable LivingEntity owner, Vec3 pos, int fuse, float power) {
public basePrimedTNT(EntityType<? extends basePrimedTNT> pEntityType, @NotNull Level pLevel, @Nullable LivingEntity owner, Vec3 pos, int fuse, float power) {
super(pEntityType, pLevel);
commonInit(pLevel, owner);
setPos(pos);

View File

@ -3,16 +3,9 @@ package com.jenny.enhancedexplosives;
import com.jenny.enhancedexplosives.particles.ArrowParticle;
import com.jenny.enhancedexplosives.particles.particles;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.TextureSheetParticle;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraftforge.client.event.RegisterParticleProvidersEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.RegistryObject;
import java.util.Iterator;
import static com.jenny.enhancedexplosives.EnhancedExplosives.MODID;

View File

@ -1,10 +1,21 @@
package com.jenny.enhancedexplosives.items;
import com.jenny.enhancedexplosives.entities.arrows.baseArrow;
import com.jenny.enhancedexplosives.entities.entities;
import net.minecraft.core.Position;
import net.minecraft.core.dispenser.AbstractProjectileDispenseBehavior;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.DispenserBlock;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import org.jetbrains.annotations.NotNull;
import static com.jenny.enhancedexplosives.EnhancedExplosives.MODID;
@ -20,4 +31,28 @@ public class items {
public static void register(IEventBus bus) {
ITEMS.register(bus);
}
public static void registerDispenser() {
class ArrowDispenseBehaviour extends AbstractProjectileDispenseBehavior {
private final EntityType<? extends baseArrow> arrowType;
public ArrowDispenseBehaviour(EntityType<? extends baseArrow> arrow) {
this.arrowType = arrow;
}
@Override
protected @NotNull Projectile getProjectile(@NotNull Level pLevel, @NotNull Position pPosition, @NotNull ItemStack pStack) {
baseArrow arrow = arrowType.create(pLevel);
assert arrow != null;
arrow.setPos(pPosition.x(), pPosition.y(), pPosition.z());
arrow.pickup = AbstractArrow.Pickup.ALLOWED;
return arrow;
}
}
DispenserBlock.registerBehavior(TNT_ARROW.get(), new ArrowDispenseBehaviour(entities.ARROW_TNT.get()));
DispenserBlock.registerBehavior(CONCUSSIVE_ARROW.get(), new ArrowDispenseBehaviour(entities.ARROW_CONCUSSIVE.get()));
DispenserBlock.registerBehavior(CARPET_ARROW.get(), new ArrowDispenseBehaviour(entities.ARROW_CARPET.get()));
DispenserBlock.registerBehavior(TUNNEL_ARROW.get(), new ArrowDispenseBehaviour(entities.ARROW_TUNNEL.get()));
}
}

View File

@ -0,0 +1,15 @@
{
"type": "minecraft:crafting_shapeless",
"category": "redstone",
"ingredients":[
{
"item": "minecraft:tnt"
},
{
"item": "minecraft:piston"
}
],
"result": {
"item": "enhancedexplosives:tnt_black_hole"
}
}