Compare commits
5 Commits
257553d374
...
39786b4612
Author | SHA1 | Date | |
---|---|---|---|
39786b4612 | |||
89a7ea18db | |||
5c5ab8c3dc | |||
57eb7e5442 | |||
4959e3e0fa |
@ -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.13.2
|
||||
# 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
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.jenny.enhancedexplosives;
|
||||
|
||||
import com.jenny.enhancedexplosives.blocks.blocks;
|
||||
import com.jenny.enhancedexplosives.config.ConfigCommon;
|
||||
import com.jenny.enhancedexplosives.particles.particles;
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
import com.jenny.enhancedexplosives.config.ConfigServer;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import com.jenny.enhancedexplosives.items.items;
|
||||
import com.jenny.enhancedexplosives.particles.particles;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@ -27,6 +27,7 @@ public class EnhancedExplosives {
|
||||
public static final String MODID = "enhancedexplosives";
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public EnhancedExplosives() {
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
|
||||
@ -40,10 +41,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, ConfigServer.SPEC, "enhancedexplosives-server.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
|
||||
@ -58,7 +61,6 @@ public class EnhancedExplosives {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onClientSetup(FMLClientSetupEvent event) {
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ConfigClient.SPEC);
|
||||
entities.registerRenderers();
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.jenny.enhancedexplosives.blocks;
|
||||
|
||||
import com.jenny.enhancedexplosives.entities.tnt.enderPrimedTNT;
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
|
||||
import com.jenny.enhancedexplosives.entities.tnt.enderPrimedTNT;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
@ -15,7 +14,6 @@ import net.minecraft.world.level.block.TntBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -95,7 +93,7 @@ public class enderTNTBlock extends TntBlock {
|
||||
}
|
||||
|
||||
public static void spawnParticles(Level level, BlockPos blockPos) {
|
||||
if (ConfigClient.tntParticles) {
|
||||
if (ConfigClient.tntParticles.get()) {
|
||||
for (int i = 1; i <= ConfigClient.calcPCount(30); i++) {
|
||||
float x = blockPos.getX() + (float) level.getRandom().nextIntBetweenInclusive(-10, 10) / 10 + 0.5F;
|
||||
float y = blockPos.getY() + (float) level.getRandom().nextIntBetweenInclusive(-10, 10) / 10;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.jenny.enhancedexplosives.blocks;
|
||||
|
||||
import com.jenny.enhancedexplosives.entities.tnt.blackHolePrimedTNT;
|
||||
import com.jenny.enhancedexplosives.entities.tnt.repulsivePrimedTNT;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -1,42 +1,37 @@
|
||||
package com.jenny.enhancedexplosives.config;
|
||||
|
||||
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 static com.jenny.enhancedexplosives.EnhancedExplosives.MODID;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class ConfigClient {
|
||||
private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
|
||||
public static final ForgeConfigSpec SPEC;
|
||||
|
||||
private static final ForgeConfigSpec.ConfigValue<Boolean> C_ARROW_PARTICLES =
|
||||
BUILDER.comment("whether to spawn client-side particles for arrows")
|
||||
.define("arrowParticles", true);
|
||||
public static final ForgeConfigSpec.ConfigValue<Boolean> arrowParticles;
|
||||
public static final ForgeConfigSpec.ConfigValue<Boolean> tntParticles;
|
||||
private static final ForgeConfigSpec.ConfigValue<Double> particlePercent;
|
||||
|
||||
private static final ForgeConfigSpec.ConfigValue<Boolean> C_TNT_PARTICLES =
|
||||
BUILDER.comment("weather to spawn client-side particles for tnt")
|
||||
.define("tntParticles", true);
|
||||
static {
|
||||
|
||||
private static final ForgeConfigSpec.ConfigValue<Double> C_PARTICLE_PERCENT =
|
||||
BUILDER.comment("amount of particles to spawn (0.0 = None, 1.0 = normal, values higher are valid too)")
|
||||
.define("arrowParticleCount", 1.0D);
|
||||
|
||||
public static final ForgeConfigSpec SPEC = BUILDER.build();
|
||||
arrowParticles =
|
||||
BUILDER.comment("particles from arrows arrows")
|
||||
.define("arrow_particles", true);
|
||||
tntParticles =
|
||||
BUILDER.comment("particles from tnt")
|
||||
.define("tnt_particles", true);
|
||||
particlePercent =
|
||||
BUILDER.comment("amount of spawned particles (0.0 = None, 1.0 = normal, values higher are valid too)")
|
||||
.define("particle_amount", 1.0D);
|
||||
|
||||
public static boolean arrowParticles, tntParticles;
|
||||
public static float particlePercent;
|
||||
SPEC = BUILDER.build();
|
||||
|
||||
@SubscribeEvent
|
||||
static void onLoad(final ModConfigEvent event)
|
||||
{
|
||||
arrowParticles = C_ARROW_PARTICLES.get();
|
||||
tntParticles = C_TNT_PARTICLES.get();
|
||||
particlePercent = C_PARTICLE_PERCENT.get().floatValue();
|
||||
}
|
||||
|
||||
public static int calcPCount(int pCount) {
|
||||
return Math.round(pCount * particlePercent);
|
||||
return (int) Math.round(pCount * particlePercent.get());
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
package com.jenny.enhancedexplosives.config;
|
||||
|
||||
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 static com.jenny.enhancedexplosives.EnhancedExplosives.MODID;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class ConfigCommon {
|
||||
private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
|
||||
|
||||
public static final ForgeConfigSpec SPEC = BUILDER.build();
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
static void onLoad(final ModConfigEvent event)
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.jenny.enhancedexplosives.config;
|
||||
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import static com.jenny.enhancedexplosives.EnhancedExplosives.MODID;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class ConfigServer {
|
||||
private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
|
||||
public static final ForgeConfigSpec SPEC;
|
||||
|
||||
public static final ForgeConfigSpec.ConfigValue<Boolean> claymoreInstantDespawn;
|
||||
public static final ForgeConfigSpec.ConfigValue<Boolean> homingAtPlayers;
|
||||
public static final ForgeConfigSpec.ConfigValue<Boolean> carpetCompactDetonation;
|
||||
|
||||
|
||||
static {
|
||||
claymoreInstantDespawn = BUILDER.comment("Claymore arrows despawn instantly upon hitting a surface")
|
||||
.define("claymore_instant_arrow_despawn", false);
|
||||
homingAtPlayers = BUILDER.comment("Homing TNTs are allowed to follow players")
|
||||
.define("homing_tnt_target_players", true);
|
||||
carpetCompactDetonation = BUILDER.comment("Carpet Arrow TNTs explode upon explosion damage; This reduces spread")
|
||||
.define("carpet_arrow_compact_detonation", true);
|
||||
|
||||
SPEC = BUILDER.build();
|
||||
}
|
||||
}
|
@ -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());
|
||||
|
@ -1,16 +1,19 @@
|
||||
package com.jenny.enhancedexplosives.datagen;
|
||||
|
||||
import com.jenny.enhancedexplosives.blocks.blocks;
|
||||
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraftforge.client.model.generators.BlockStateProvider;
|
||||
import net.minecraftforge.client.model.generators.ConfiguredModel;
|
||||
import net.minecraftforge.client.model.generators.ModelFile;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.client.model.generators.ModelFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.jenny.enhancedexplosives.EnhancedExplosives.MODID;
|
||||
|
||||
@ -37,20 +40,20 @@ public class ModBlockStateProvider extends BlockStateProvider {
|
||||
SideOnlyTNT(blocks.TNT_HOMING);
|
||||
}
|
||||
|
||||
private void blockWithItem(RegistryObject<Block> blockRegistryObject) {
|
||||
private void blockWithItem(@NotNull RegistryObject<Block> blockRegistryObject) {
|
||||
simpleBlockWithItem(blockRegistryObject.get(), cubeAll(blockRegistryObject.get()));
|
||||
}
|
||||
|
||||
private void SideTop(RegistryObject<Block> blockRegistryObject) {
|
||||
private void SideTop(@NotNull RegistryObject<Block> blockRegistryObject) {
|
||||
simpleBlockWithItem(blockRegistryObject.get(), topSide(blockRegistryObject.get()));
|
||||
}
|
||||
|
||||
private void blockItem(RegistryObject<Block> blockRegistryObject) {
|
||||
private void blockItem(@NotNull RegistryObject<Block> blockRegistryObject) {
|
||||
simpleBlockItem(blockRegistryObject.get(), new ModelFile.UncheckedModelFile(MODID +
|
||||
":block/" + ForgeRegistries.BLOCKS.getKey(blockRegistryObject.get()).getPath()));
|
||||
":block/" + Objects.requireNonNull(ForgeRegistries.BLOCKS.getKey(blockRegistryObject.get())).getPath()));
|
||||
}
|
||||
|
||||
private void topBottom2Sides(RegistryObject<Block> blockRegistryObject) {
|
||||
private void topBottom2Sides(@NotNull RegistryObject<Block> blockRegistryObject) {
|
||||
simpleBlockWithItem(blockRegistryObject.get(), northEastTopBottom(blockRegistryObject.get()));
|
||||
}
|
||||
|
||||
@ -58,22 +61,22 @@ public class ModBlockStateProvider extends BlockStateProvider {
|
||||
return ForgeRegistries.BLOCKS.getKey(block);
|
||||
}
|
||||
|
||||
private String name(Block block) {
|
||||
private @NotNull String name(Block block) {
|
||||
return key(block).getPath();
|
||||
}
|
||||
|
||||
private ResourceLocation extend(ResourceLocation rl, String suffix) {
|
||||
private ResourceLocation extend(@NotNull ResourceLocation rl, String suffix) {
|
||||
return new ResourceLocation(rl.getNamespace(), rl.getPath() + suffix);
|
||||
}
|
||||
|
||||
public void sideTopBottom(RegistryObject<Block> blockRegistryObject) {
|
||||
public void sideTopBottom(@NotNull RegistryObject<Block> blockRegistryObject) {
|
||||
Block block = blockRegistryObject.get();
|
||||
ModelFile model = models().cubeBottomTop(name(block), extend(blockTexture(block), "_side"), extend(blockTexture(block), "_bottom"), extend(blockTexture(block), "_top"));
|
||||
this.getVariantBuilder(block).forAllStates(blockState -> ConfiguredModel.builder().modelFile(model).build());
|
||||
simpleBlockItem(block, model);
|
||||
}
|
||||
|
||||
public void SideOnlyTNT(RegistryObject<Block> blockRegistryObject) {
|
||||
public void SideOnlyTNT(@NotNull RegistryObject<Block> blockRegistryObject) {
|
||||
Block block = blockRegistryObject.get();
|
||||
ModelFile model = models().cubeBottomTop(name(block), extend(blockTexture(block), "_side"), extend(blockTexture(Blocks.TNT), "_bottom"), extend(blockTexture(Blocks.TNT), "_top"));
|
||||
this.getVariantBuilder(block).forAllStates(blockState -> ConfiguredModel.builder().modelFile(model).build());
|
||||
|
@ -1,11 +1,9 @@
|
||||
package com.jenny.enhancedexplosives.datagen;
|
||||
|
||||
import com.jenny.enhancedexplosives.items.items;
|
||||
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.client.model.generators.ItemModelBuilder;
|
||||
import net.minecraftforge.client.model.generators.ItemModelProvider;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
@ -25,8 +23,8 @@ public class ModItemModelProvider extends ItemModelProvider {
|
||||
simpleItem(items.TUNNEL_ARROW);
|
||||
}
|
||||
|
||||
private ItemModelBuilder simpleItem(RegistryObject<Item> item) {
|
||||
return withExistingParent(item.getId().getPath(),
|
||||
private void simpleItem(RegistryObject<Item> item) {
|
||||
withExistingParent(item.getId().getPath(),
|
||||
new ResourceLocation("item/generated")).texture("layer0",
|
||||
new ResourceLocation(MODID,"item/" + item.getId().getPath()));
|
||||
}
|
||||
|
@ -1,237 +1,55 @@
|
||||
package com.jenny.enhancedexplosives.entities.arrows;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||
import net.minecraft.world.entity.projectile.Arrow;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.alchemy.Potion;
|
||||
import net.minecraft.world.item.alchemy.PotionUtils;
|
||||
import net.minecraft.world.item.alchemy.Potions;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
public class baseArrow extends AbstractArrow {
|
||||
private static final int EXPOSED_POTION_DECAY_TIME = 600;
|
||||
private static final int NO_EFFECT_COLOR = -1;
|
||||
private static final EntityDataAccessor<Integer> ID_EFFECT_COLOR = SynchedEntityData.defineId(Arrow.class, EntityDataSerializers.INT);
|
||||
private static final byte EVENT_POTION_PUFF = 0;
|
||||
private Potion potion = Potions.EMPTY;
|
||||
private final Set<MobEffectInstance> effects = Sets.newHashSet();
|
||||
private boolean fixedColor;
|
||||
private int tick = 0;
|
||||
|
||||
public baseArrow(EntityType<? extends baseArrow> pEntityType, Level pLevel) {
|
||||
super(pEntityType, pLevel);
|
||||
}
|
||||
|
||||
public baseArrow(Level pLevel, double pX, double pY, double pZ, EntityType<? extends baseArrow> pEntityType) {
|
||||
super(pEntityType, pX, pY, pZ, pLevel);
|
||||
}
|
||||
|
||||
public baseArrow(Level pLevel, LivingEntity pShooter, EntityType<? extends baseArrow> pEntityType) {
|
||||
super(pEntityType, pShooter, pLevel);
|
||||
}
|
||||
|
||||
public void setEffectsFromItem(ItemStack pStack) {
|
||||
if (pStack.is(Items.TIPPED_ARROW)) {
|
||||
this.potion = PotionUtils.getPotion(pStack);
|
||||
Collection<MobEffectInstance> collection = PotionUtils.getCustomEffects(pStack);
|
||||
if (!collection.isEmpty()) {
|
||||
for(MobEffectInstance mobeffectinstance : collection) {
|
||||
this.effects.add(new MobEffectInstance(mobeffectinstance));
|
||||
}
|
||||
}
|
||||
|
||||
int i = getCustomColor(pStack);
|
||||
if (i == -1) {
|
||||
this.updateColor();
|
||||
} else {
|
||||
this.setFixedColor(i);
|
||||
}
|
||||
} else if (pStack.is(Items.ARROW)) {
|
||||
this.potion = Potions.EMPTY;
|
||||
this.effects.clear();
|
||||
this.entityData.set(ID_EFFECT_COLOR, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int getCustomColor(ItemStack pStack) {
|
||||
CompoundTag compoundtag = pStack.getTag();
|
||||
return compoundtag != null && compoundtag.contains("CustomPotionColor", 99) ? compoundtag.getInt("CustomPotionColor") : -1;
|
||||
}
|
||||
|
||||
private void updateColor() {
|
||||
this.fixedColor = false;
|
||||
if (this.potion == Potions.EMPTY && this.effects.isEmpty()) {
|
||||
this.entityData.set(ID_EFFECT_COLOR, -1);
|
||||
} else {
|
||||
this.entityData.set(ID_EFFECT_COLOR, PotionUtils.getColor(PotionUtils.getAllEffects(this.potion, this.effects)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addEffect(MobEffectInstance pEffectInstance) {
|
||||
this.effects.add(pEffectInstance);
|
||||
this.getEntityData().set(ID_EFFECT_COLOR, PotionUtils.getColor(PotionUtils.getAllEffects(this.potion, this.effects)));
|
||||
}
|
||||
|
||||
protected void defineSynchedData() {
|
||||
super.defineSynchedData();
|
||||
this.entityData.define(ID_EFFECT_COLOR, -1);
|
||||
public baseArrow(Level pLevel, EntityType<? extends baseArrow> pEntityType) {
|
||||
super(pEntityType, pLevel);
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (this.level().isClientSide) {
|
||||
if (this.inGround) {
|
||||
if (this.inGroundTime % 5 == 0) {
|
||||
this.makeParticle(1);
|
||||
}
|
||||
} else {
|
||||
if (!this.inGround && ConfigClient.arrowParticles.get()) {
|
||||
spawnParticles(0);
|
||||
}
|
||||
this.tick++;
|
||||
} else if (this.inGround && this.inGroundTime != 0 && !this.effects.isEmpty() && this.inGroundTime >= 600) {
|
||||
this.level().broadcastEntityEvent(this, (byte)0);
|
||||
this.potion = Potions.EMPTY;
|
||||
this.effects.clear();
|
||||
this.entityData.set(ID_EFFECT_COLOR, -1);
|
||||
}
|
||||
}
|
||||
|
||||
private void makeParticle(int pParticleAmount) {
|
||||
int i = this.getColor();
|
||||
if (i != -1 && pParticleAmount > 0) {
|
||||
double d0 = (double)(i >> 16 & 255) / 255.0D;
|
||||
double d1 = (double)(i >> 8 & 255) / 255.0D;
|
||||
double d2 = (double)(i >> 0 & 255) / 255.0D;
|
||||
|
||||
for(int j = 0; j < pParticleAmount; ++j) {
|
||||
this.level().addParticle(ParticleTypes.ENTITY_EFFECT, this.getRandomX(0.5D), this.getRandomY(), this.getRandomZ(0.5D), d0, d1, d2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return this.entityData.get(ID_EFFECT_COLOR);
|
||||
}
|
||||
|
||||
private void setFixedColor(int pFixedColor) {
|
||||
this.fixedColor = true;
|
||||
this.entityData.set(ID_EFFECT_COLOR, pFixedColor);
|
||||
}
|
||||
|
||||
public void addAdditionalSaveData(@NotNull CompoundTag pCompound) {
|
||||
super.addAdditionalSaveData(pCompound);
|
||||
if (this.potion != Potions.EMPTY) {
|
||||
pCompound.putString("Potion", BuiltInRegistries.POTION.getKey(this.potion).toString());
|
||||
}
|
||||
|
||||
if (this.fixedColor) {
|
||||
pCompound.putInt("Color", this.getColor());
|
||||
}
|
||||
|
||||
if (!this.effects.isEmpty()) {
|
||||
ListTag listtag = new ListTag();
|
||||
|
||||
for(MobEffectInstance mobeffectinstance : this.effects) {
|
||||
listtag.add(mobeffectinstance.save(new CompoundTag()));
|
||||
}
|
||||
|
||||
pCompound.put("CustomPotionEffects", listtag);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void readAdditionalSaveData(@NotNull CompoundTag pCompound) {
|
||||
super.readAdditionalSaveData(pCompound);
|
||||
if (pCompound.contains("Potion", 8)) {
|
||||
this.potion = PotionUtils.getPotion(pCompound);
|
||||
}
|
||||
|
||||
for(MobEffectInstance mobeffectinstance : PotionUtils.getCustomEffects(pCompound)) {
|
||||
this.addEffect(mobeffectinstance);
|
||||
}
|
||||
|
||||
if (pCompound.contains("Color", 99)) {
|
||||
this.setFixedColor(pCompound.getInt("Color"));
|
||||
} else {
|
||||
this.updateColor();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void doPostHurtEffects(@NotNull LivingEntity pLiving) {
|
||||
super.doPostHurtEffects(pLiving);
|
||||
Entity entity = this.getEffectSource();
|
||||
|
||||
for(MobEffectInstance mobeffectinstance : this.potion.getEffects()) {
|
||||
pLiving.addEffect(new MobEffectInstance(mobeffectinstance.getEffect(), Math.max(mobeffectinstance.mapDuration((p_268168_) -> {
|
||||
return p_268168_ / 8;
|
||||
}), 1), mobeffectinstance.getAmplifier(), mobeffectinstance.isAmbient(), mobeffectinstance.isVisible()), entity);
|
||||
}
|
||||
|
||||
if (!this.effects.isEmpty()) {
|
||||
for(MobEffectInstance mobeffectinstance1 : this.effects) {
|
||||
pLiving.addEffect(mobeffectinstance1, entity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected ItemStack getPickupItem() {
|
||||
if (this.effects.isEmpty() && this.potion == Potions.EMPTY) {
|
||||
return new ItemStack(Items.ARROW);
|
||||
} else {
|
||||
ItemStack itemstack = new ItemStack(Items.TIPPED_ARROW);
|
||||
PotionUtils.setPotion(itemstack, this.potion);
|
||||
PotionUtils.setCustomEffects(itemstack, this.effects);
|
||||
if (this.fixedColor) {
|
||||
itemstack.getOrCreateTag().putInt("CustomPotionColor", this.getColor());
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleEntityEvent(byte pId) {
|
||||
if (pId == 0) {
|
||||
int i = this.getColor();
|
||||
if (i != -1) {
|
||||
double d0 = (double)(i >> 16 & 255) / 255.0D;
|
||||
double d1 = (double)(i >> 8 & 255) / 255.0D;
|
||||
double d2 = (double)(i >> 0 & 255) / 255.0D;
|
||||
|
||||
for(int j = 0; j < 20; ++j) {
|
||||
this.level().addParticle(ParticleTypes.ENTITY_EFFECT, this.getRandomX(0.5D), this.getRandomY(), this.getRandomZ(0.5D), d0, d1, d2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.handleEntityEvent(pId);
|
||||
}
|
||||
|
||||
protected Vec3 particlePos(double dist) {
|
||||
Double speed = getDeltaMovement().length();
|
||||
return new Vec3(
|
||||
level().getRandom().nextIntBetweenInclusive(-100, 100),
|
||||
level().getRandom().nextIntBetweenInclusive(-100, 100),
|
||||
level().getRandom().nextIntBetweenInclusive(-100, 100)
|
||||
).normalize().scale(dist + ((double) level().getRandom().nextIntBetweenInclusive(0, 100) / 100)).add(position());
|
||||
}
|
||||
|
||||
public void spawnParticles(float partialTicks) {
|
||||
|
||||
}
|
||||
|
||||
public int getTick() {
|
||||
|
@ -54,14 +54,10 @@ public class carpetArrow extends baseArrow {
|
||||
|
||||
@Override
|
||||
public void spawnParticles(float partialTicks) {
|
||||
for (int i = 1; i <= ConfigClient.calcPCount(3); i++) {
|
||||
for (int i = 1; i <= ConfigClient.calcPCount(5); i++) {
|
||||
double m = (double) level().getRandom().nextIntBetweenInclusive(-100, 100) / 100;
|
||||
Vec3 DeltaMovement = getDeltaMovement();
|
||||
Vec3 pos = new Vec3(
|
||||
(double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10,
|
||||
0,
|
||||
(double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10
|
||||
).normalize().multiply(m, 0, m).add(getPosition(partialTicks));
|
||||
Vec3 pos = particlePos(0.5);
|
||||
level().addParticle(particles.CARPET_ARROW_PARTICLE.get(), pos.x, pos.y, pos.z, DeltaMovement.x, DeltaMovement.y, DeltaMovement.z);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.jenny.enhancedexplosives.entities.arrows;
|
||||
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
import com.jenny.enhancedexplosives.config.ConfigServer;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import com.jenny.enhancedexplosives.items.items;
|
||||
import com.jenny.enhancedexplosives.particles.particles;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.damagesource.DamageType;
|
||||
import net.minecraft.world.damagesource.DamageTypes;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@ -20,13 +20,13 @@ public class carpetArrowPart extends baseArrow {
|
||||
}
|
||||
|
||||
public carpetArrowPart(Level pLevel, LivingEntity pShooter) {
|
||||
super(pLevel, pShooter, entities.ARROW_CARPET_PART.get());
|
||||
super(pLevel, entities.ARROW_CARPET_PART.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (this.inGround || this.hurtMarked) {
|
||||
if (this.inGround || (this.hurtMarked && !this.level().isClientSide && ConfigServer.carpetCompactDetonation.get())) {
|
||||
explode();
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,20 @@
|
||||
package com.jenny.enhancedexplosives.entities.arrows;
|
||||
|
||||
import com.jenny.enhancedexplosives.config.ConfigServer;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import com.jenny.enhancedexplosives.items.items;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class claymoreArrow extends baseArrow{
|
||||
private final int r = level().isClientSide ? 0 : (ConfigServer.claymoreInstantDespawn.get() ? -20 : level().getRandom().nextInt(0, 20));
|
||||
|
||||
public claymoreArrow(EntityType<claymoreArrow> pEntityType, Level pLevel) {
|
||||
super(pEntityType, pLevel);
|
||||
|
||||
}
|
||||
|
||||
public claymoreArrow(@NotNull Level pLevel, @NotNull LivingEntity pShooter) {
|
||||
@ -23,6 +26,14 @@ public class claymoreArrow extends baseArrow{
|
||||
pTarget.hurt(damageSources().mobProjectile(this, (LivingEntity) getOwner()), 15);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (!level().isClientSide && this.inGroundTime > 20 + r) {
|
||||
discard();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected ItemStack getPickupItem() {
|
||||
|
@ -1,10 +1,9 @@
|
||||
package com.jenny.enhancedexplosives.entities.arrows;
|
||||
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import com.jenny.enhancedexplosives.items.items;
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
import com.jenny.enhancedexplosives.particles.particles;
|
||||
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@ -43,15 +42,10 @@ public class concussiveArrow extends baseArrow{
|
||||
|
||||
@Override
|
||||
public void spawnParticles(float partialTicks) {
|
||||
for (int i = 1; i <= ConfigClient.calcPCount(3); i++) {
|
||||
double m = (double) level().getRandom().nextIntBetweenInclusive(- 100, 100) / 100;
|
||||
Vec3 DeltaMovement = getDeltaMovement();
|
||||
Vec3 pos = new Vec3(
|
||||
(double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10,
|
||||
0,
|
||||
(double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10
|
||||
).normalize().multiply(m, m, m).add(getPosition(partialTicks));
|
||||
level().addParticle(particles.CONCUSSIVE_ARROW_PARTICLE.get(), pos.x, pos.y, pos.z, DeltaMovement.x, DeltaMovement.y, DeltaMovement.z);
|
||||
for (int i = 1; i <= ConfigClient.calcPCount(5); i++) {
|
||||
Vec3 delta = getDeltaMovement();
|
||||
Vec3 pos = particlePos(0.5);
|
||||
level().addParticle(particles.CONCUSSIVE_ARROW_PARTICLE.get(), pos.x, pos.y, pos.z, delta.x, delta.y, delta.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
package com.jenny.enhancedexplosives.entities.arrows;
|
||||
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
import com.jenny.enhancedexplosives.items.items;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
|
||||
import com.jenny.enhancedexplosives.items.items;
|
||||
import com.jenny.enhancedexplosives.particles.particles;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@ -43,14 +42,10 @@ public class tntArrow extends baseArrow {
|
||||
|
||||
@Override
|
||||
public void spawnParticles(float partialTicks) {
|
||||
for (int i = 1; i <= ConfigClient.calcPCount(3); i++) {
|
||||
for (int i = 1; i <= ConfigClient.calcPCount(5); i++) {
|
||||
double m = (double) level().getRandom().nextIntBetweenInclusive(- 100, 100) / 100;
|
||||
Vec3 DeltaMovement = getDeltaMovement();
|
||||
Vec3 pos = new Vec3(
|
||||
(double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10,
|
||||
0,
|
||||
(double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10
|
||||
).normalize().multiply(m, m, m).add(getPosition(partialTicks));
|
||||
Vec3 pos = particlePos(0.5);
|
||||
level().addParticle(particles.TNT_ARROW_PARTICLE.get(), pos.x, pos.y, pos.z, DeltaMovement.x, DeltaMovement.y, DeltaMovement.z);
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,9 @@ import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class tunnelArrow extends baseArrow{
|
||||
protected static int explosionCount = 12;
|
||||
protected static int spacing = 2;
|
||||
protected static float power = 8;
|
||||
protected static final int explosionCount = 12;
|
||||
protected static final int spacing = 2;
|
||||
protected static final float power = 8;
|
||||
|
||||
public tunnelArrow(EntityType<tunnelArrow> pEntityType, Level pLevel) {
|
||||
super(pEntityType, pLevel);
|
||||
@ -43,11 +43,9 @@ public class tunnelArrow extends baseArrow{
|
||||
}
|
||||
|
||||
protected void explode() {
|
||||
// sync();
|
||||
Vec3 rot = getTargetVec( - getXRot(), - getYRot(), 0);
|
||||
for (int i = 0; i < explosionCount; i++) {
|
||||
Vec3 pos = position().add(rot.multiply(i * spacing, i * spacing, i * spacing));
|
||||
System.out.println(level().isClientSide + "|" + i + "|" + pos + "|" + getXRot() + "|" + getYRot());
|
||||
level().explode(this, pos.x, pos.y, pos.z,
|
||||
power, Level.ExplosionInteraction.TNT);
|
||||
}
|
||||
@ -62,14 +60,10 @@ public class tunnelArrow extends baseArrow{
|
||||
|
||||
@Override
|
||||
public void spawnParticles(float partialTicks) {
|
||||
for (int i = 1; i <= ConfigClient.calcPCount(3); i++) {
|
||||
for (int i = 1; i <= ConfigClient.calcPCount(5); i++) {
|
||||
double m = (double) level().getRandom().nextIntBetweenInclusive(- 100, 100) / 100;
|
||||
Vec3 DeltaMovement = getDeltaMovement();
|
||||
Vec3 pos = new Vec3(
|
||||
(double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10,
|
||||
0,
|
||||
(double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10
|
||||
).normalize().multiply(m, m, m).add(getPosition(partialTicks));
|
||||
Vec3 pos = particlePos(0.5);
|
||||
level().addParticle(particles.TUNNEL_ARROW_PARTICLE.get(), pos.x, pos.y, pos.z, DeltaMovement.x, DeltaMovement.y, DeltaMovement.z);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.jenny.enhancedexplosives.entities.client;
|
||||
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
import com.jenny.enhancedexplosives.entities.tnt.basePrimedTNT;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.jenny.enhancedexplosives.entities.client;
|
||||
|
||||
import com.jenny.enhancedexplosives.entities.arrows.baseArrow;
|
||||
import com.jenny.enhancedexplosives.config.*;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
@ -13,7 +11,6 @@ import net.minecraft.client.renderer.entity.TntMinecartRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TNTArrowRenderer extends EntityRenderer<baseArrow> {
|
||||
|
@ -2,7 +2,6 @@ package com.jenny.enhancedexplosives.entities.throwable;
|
||||
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import com.jenny.enhancedexplosives.entities.tnt.basePrimedTNT;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
|
@ -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);
|
||||
@ -67,7 +67,7 @@ public abstract class basePrimedTNT extends Entity implements TraceableEntity {
|
||||
|
||||
public void tick() {
|
||||
if (level().isClientSide) {
|
||||
if (ConfigClient.tntParticles) {
|
||||
if (ConfigClient.tntParticles.get()) {
|
||||
spawnParticles();
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,25 @@
|
||||
package com.jenny.enhancedexplosives.entities.tnt;
|
||||
|
||||
import com.jenny.enhancedexplosives.blocks.blocks;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import com.jenny.enhancedexplosives.config.ConfigServer;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.world.entity.*;
|
||||
import net.minecraft.world.entity.ai.targeting.TargetingConditions;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class homingPrimedTNT extends basePrimedTNT {
|
||||
private static final EntityDataAccessor<Float> DATA_SPEED_ID = SynchedEntityData.defineId(homingPrimedTNT.class, EntityDataSerializers.FLOAT);
|
||||
@ -51,10 +53,34 @@ public class homingPrimedTNT extends basePrimedTNT {
|
||||
}
|
||||
|
||||
public void findTarget() {
|
||||
target = closestEntity(getEntities());
|
||||
}
|
||||
|
||||
private LivingEntity closestEntity(List<LivingEntity> entities) {
|
||||
double dist = Double.MAX_VALUE;
|
||||
LivingEntity target = null;
|
||||
for (LivingEntity e : entities) {
|
||||
double newDist = e.position().distanceTo(position());
|
||||
if (newDist < dist) {
|
||||
target = e;
|
||||
dist = newDist;
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
protected List<LivingEntity> getEntities() {
|
||||
List<LivingEntity> ret_list = new ArrayList<>();
|
||||
Vec3 corner1 = this.position().subtract(15, 15, 15);
|
||||
Vec3 corner2 = this.position().add(15, 15, 15);
|
||||
AABB boundingBox = new AABB(corner1, corner2);
|
||||
target = this.level().getNearestEntity(LivingEntity.class, TargetingConditions.forNonCombat(), null, this.getX(), this.getY(), this.getZ(), boundingBox);
|
||||
|
||||
for (LivingEntity entity : level().getEntitiesOfClass(LivingEntity.class, boundingBox)) {
|
||||
if (level().getPlayerByUUID(entity.getUUID()) == null || ConfigServer.homingAtPlayers.get()) { // prevent aiming at player if config says so
|
||||
ret_list.add(entity);
|
||||
}
|
||||
}
|
||||
return ret_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,8 +34,7 @@ public class repulsivePrimedTNT extends basePrimedTNT {
|
||||
double dist = getTargetDist(target);
|
||||
float speed = getSpeed();
|
||||
Vec3 mult = new Vec3(speed / dist, speed / dist, speed / dist);
|
||||
Vec3 ret = target.position().subtract(this.position()).normalize().multiply(mult);
|
||||
return ret;
|
||||
return target.position().subtract(this.position()).normalize().multiply(mult);
|
||||
}
|
||||
|
||||
public double getTargetDist(Entity target) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"category": "redstone",
|
||||
"ingredients":[
|
||||
{
|
||||
"item": "minecraft:tnt"
|
||||
},
|
||||
{
|
||||
"item": "minecraft:piston"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "enhancedexplosives:tnt_black_hole"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user