mirror of
https://github.com/FatherToast/SpecialMobs.git
synced 2025-08-22 10:01:23 +00:00
Evil stuff
This commit is contained in:
parent
b5f123abd9
commit
a1d0edd7e0
11 changed files with 176 additions and 5 deletions
|
@ -10,6 +10,7 @@ import fathertoast.specialmobs.common.entity.witherskeleton.NinjaWitherSkeletonE
|
||||||
import mcp.MethodsReturnNonnullByDefault;
|
import mcp.MethodsReturnNonnullByDefault;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.ItemRenderer;
|
import net.minecraft.client.renderer.ItemRenderer;
|
||||||
|
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||||
import net.minecraft.client.renderer.entity.SpriteRenderer;
|
import net.minecraft.client.renderer.entity.SpriteRenderer;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package fathertoast.specialmobs.common.core.register;
|
package fathertoast.specialmobs.common.core.register;
|
||||||
|
|
||||||
import fathertoast.specialmobs.common.core.SpecialMobs;
|
import fathertoast.specialmobs.common.core.SpecialMobs;
|
||||||
|
import fathertoast.specialmobs.common.item.IncorporealFireChargeItem;
|
||||||
import fathertoast.specialmobs.common.item.SyringeItem;
|
import fathertoast.specialmobs.common.item.SyringeItem;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
|
@ -22,6 +23,7 @@ public class SMItems {
|
||||||
|
|
||||||
|
|
||||||
public static final RegistryObject<Item> SYRINGE = registerSimpleItem("syringe", SyringeItem::new);
|
public static final RegistryObject<Item> SYRINGE = registerSimpleItem("syringe", SyringeItem::new);
|
||||||
|
public static final RegistryObject<Item> INCORPOREAL_FIREBALL = registerSimpleItem("incorporeal_fire_charge", IncorporealFireChargeItem::new);
|
||||||
|
|
||||||
|
|
||||||
/** Registers an entity type's spawn egg item to the deferred register. */
|
/** Registers an entity type's spawn egg item to the deferred register. */
|
||||||
|
|
|
@ -3,6 +3,7 @@ package fathertoast.specialmobs.common.entity.ghast;
|
||||||
import fathertoast.specialmobs.common.bestiary.BestiaryInfo;
|
import fathertoast.specialmobs.common.bestiary.BestiaryInfo;
|
||||||
import fathertoast.specialmobs.common.bestiary.MobFamily;
|
import fathertoast.specialmobs.common.bestiary.MobFamily;
|
||||||
import fathertoast.specialmobs.common.bestiary.SpecialMob;
|
import fathertoast.specialmobs.common.bestiary.SpecialMob;
|
||||||
|
import fathertoast.specialmobs.common.core.register.SMItems;
|
||||||
import fathertoast.specialmobs.common.entity.SpecialMobData;
|
import fathertoast.specialmobs.common.entity.SpecialMobData;
|
||||||
import fathertoast.specialmobs.common.entity.projectile.CorporealShiftFireballEntity;
|
import fathertoast.specialmobs.common.entity.projectile.CorporealShiftFireballEntity;
|
||||||
import fathertoast.specialmobs.common.util.AttributeHelper;
|
import fathertoast.specialmobs.common.util.AttributeHelper;
|
||||||
|
@ -60,7 +61,7 @@ public class CorporealShiftGhastEntity extends _SpecialGhastEntity {
|
||||||
public static void buildLootTable( LootTableBuilder loot ) {
|
public static void buildLootTable( LootTableBuilder loot ) {
|
||||||
addBaseLoot( loot );
|
addBaseLoot( loot );
|
||||||
// TODO - Uh uhm uhhhhh hmmm..
|
// TODO - Uh uhm uhhhhh hmmm..
|
||||||
loot.addSemicommonDrop( "semicommon", Items.POISONOUS_POTATO );
|
loot.addSemicommonDrop( "semicommon", SMItems.INCORPOREAL_FIREBALL.get() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SpecialMob.Factory
|
@SpecialMob.Factory
|
||||||
|
|
|
@ -3,6 +3,7 @@ package fathertoast.specialmobs.common.entity.projectile;
|
||||||
import fathertoast.specialmobs.common.bestiary.SpecialMob;
|
import fathertoast.specialmobs.common.bestiary.SpecialMob;
|
||||||
import fathertoast.specialmobs.common.core.SpecialMobs;
|
import fathertoast.specialmobs.common.core.SpecialMobs;
|
||||||
import fathertoast.specialmobs.common.core.register.SMEntities;
|
import fathertoast.specialmobs.common.core.register.SMEntities;
|
||||||
|
import fathertoast.specialmobs.common.core.register.SMItems;
|
||||||
import fathertoast.specialmobs.common.entity.ghast.CorporealShiftGhastEntity;
|
import fathertoast.specialmobs.common.entity.ghast.CorporealShiftGhastEntity;
|
||||||
import fathertoast.specialmobs.common.util.References;
|
import fathertoast.specialmobs.common.util.References;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -50,7 +51,14 @@ public class CorporealShiftFireballEntity extends AbstractFireballEntity {
|
||||||
super(SMEntities.CORPOREAL_FIREBALL.get(), ghast, x, y, z, world);
|
super(SMEntities.CORPOREAL_FIREBALL.get(), ghast, x, y, z, world);
|
||||||
setCorporeal(ghast.isCorporeal());
|
setCorporeal(ghast.isCorporeal());
|
||||||
target = ghast.getTarget();
|
target = ghast.getTarget();
|
||||||
setItem(isCorporeal() ? new ItemStack(Items.FIRE_CHARGE) : new ItemStack(Items.ENDER_PEARL));
|
setItem(isCorporeal() ? new ItemStack(Items.FIRE_CHARGE) : new ItemStack(SMItems.INCORPOREAL_FIREBALL.get()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public CorporealShiftFireballEntity(World world, PlayerEntity owner, LivingEntity target, double x, double y, double z) {
|
||||||
|
super(SMEntities.CORPOREAL_FIREBALL.get(), owner, x, y, z, world);
|
||||||
|
setCorporeal(false);
|
||||||
|
this.target = target;
|
||||||
|
setItem(new ItemStack(SMItems.INCORPOREAL_FIREBALL.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SpecialMob.LanguageProvider
|
@SpecialMob.LanguageProvider
|
||||||
|
@ -97,6 +105,7 @@ public class CorporealShiftFireballEntity extends AbstractFireballEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean shouldBurn() {
|
protected boolean shouldBurn() {
|
||||||
|
// Hee hee hee haw
|
||||||
return isCorporeal();
|
return isCorporeal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +113,8 @@ public class CorporealShiftFireballEntity extends AbstractFireballEntity {
|
||||||
protected void onHit(RayTraceResult traceResult) {
|
protected void onHit(RayTraceResult traceResult) {
|
||||||
super.onHit(traceResult);
|
super.onHit(traceResult);
|
||||||
|
|
||||||
|
// Only go boom if the fireball is corporeal.
|
||||||
|
// If not, pass through blocks to be a menace.
|
||||||
if (!level.isClientSide && isCorporeal()) {
|
if (!level.isClientSide && isCorporeal()) {
|
||||||
shouldExplode = true;
|
shouldExplode = true;
|
||||||
}
|
}
|
||||||
|
@ -119,6 +130,8 @@ public class CorporealShiftFireballEntity extends AbstractFireballEntity {
|
||||||
|
|
||||||
if (!isCorporeal()) {
|
if (!isCorporeal()) {
|
||||||
// TODO - Figure out why this is cringe
|
// TODO - Figure out why this is cringe
|
||||||
|
// TODO part 2. - What the fuck
|
||||||
|
// TODO part 3. - HELP
|
||||||
SpecialMobs.LOG.info("X={}, XO={}", target.getX(), target.xo);
|
SpecialMobs.LOG.info("X={}, XO={}", target.getX(), target.xo);
|
||||||
SpecialMobs.LOG.info("Z={}, ZO={}", target.getZ(), target.zo);
|
SpecialMobs.LOG.info("Z={}, ZO={}", target.getZ(), target.zo);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package fathertoast.specialmobs.common.item;
|
||||||
|
|
||||||
|
import fathertoast.specialmobs.common.bestiary.SpecialMob;
|
||||||
|
import fathertoast.specialmobs.common.network.NetworkHelper;
|
||||||
|
import fathertoast.specialmobs.common.util.EntityUtil;
|
||||||
|
import fathertoast.specialmobs.common.util.References;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemGroup;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Rarity;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.SoundCategory;
|
||||||
|
import net.minecraft.util.SoundEvents;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class IncorporealFireChargeItem extends Item {
|
||||||
|
|
||||||
|
public IncorporealFireChargeItem() {
|
||||||
|
super(new Item.Properties().stacksTo(1).tab(ItemGroup.TAB_MISC).rarity(Rarity.UNCOMMON));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SpecialMob.LanguageProvider
|
||||||
|
public static String[] getTranslations( String langKey ) {
|
||||||
|
return References.translations( langKey, "Incorporeal Fire Charge",
|
||||||
|
"", "", "", "", "", "" );//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||||
|
if (world.isClientSide) {
|
||||||
|
Entity entity = EntityUtil.getClientMouseOver(player);
|
||||||
|
|
||||||
|
if (entity instanceof LivingEntity) {
|
||||||
|
NetworkHelper.spawnIncorporealFireball(player, (LivingEntity) entity);
|
||||||
|
}
|
||||||
|
world.playSound(null, player.blockPosition(), SoundEvents.FIRECHARGE_USE, SoundCategory.BLOCKS, 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F);
|
||||||
|
}
|
||||||
|
return ActionResult.sidedSuccess(player.getItemInHand(hand), world.isClientSide);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,14 @@
|
||||||
package fathertoast.specialmobs.common.network;
|
package fathertoast.specialmobs.common.network;
|
||||||
|
|
||||||
|
import fathertoast.specialmobs.common.network.message.C2SSpawnIncorporealFireball;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class NetworkHelper {
|
public class NetworkHelper {
|
||||||
|
|
||||||
|
public static void spawnIncorporealFireball(@Nonnull PlayerEntity player, @Nonnull LivingEntity livingEntity) {
|
||||||
|
PacketHandler.CHANNEL.sendToServer(new C2SSpawnIncorporealFireball(player.getUUID(), livingEntity.getId()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package fathertoast.specialmobs.common.network;
|
package fathertoast.specialmobs.common.network;
|
||||||
|
|
||||||
import fathertoast.specialmobs.common.core.SpecialMobs;
|
import fathertoast.specialmobs.common.core.SpecialMobs;
|
||||||
|
import fathertoast.specialmobs.common.network.message.C2SSpawnIncorporealFireball;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
@ -33,11 +34,11 @@ public class PacketHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void registerMessages() {
|
public final void registerMessages() {
|
||||||
|
registerMessage(C2SSpawnIncorporealFireball.class, C2SSpawnIncorporealFireball::encode, C2SSpawnIncorporealFireball::decode, C2SSpawnIncorporealFireball::handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <MSG> void registerMessage(Class<MSG> messageType, BiConsumer<MSG, PacketBuffer> encoder, Function<PacketBuffer, MSG> decoder, BiConsumer<MSG, Supplier<NetworkEvent.Context>> messageConsumer) {
|
public <MSG> void registerMessage(Class<MSG> messageType, BiConsumer<MSG, PacketBuffer> encoder, Function<PacketBuffer, MSG> decoder, BiConsumer<MSG, Supplier<NetworkEvent.Context>> handler) {
|
||||||
CHANNEL.registerMessage(this.messageIndex++, messageType, encoder, decoder, messageConsumer, Optional.empty());
|
CHANNEL.registerMessage(this.messageIndex++, messageType, encoder, decoder, handler, Optional.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package fathertoast.specialmobs.common.network.message;
|
||||||
|
|
||||||
|
import fathertoast.specialmobs.common.network.work.ServerWork;
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraftforge.fml.network.NetworkEvent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class C2SSpawnIncorporealFireball {
|
||||||
|
|
||||||
|
public final UUID playerUUID;
|
||||||
|
public final int targetEntityID;
|
||||||
|
|
||||||
|
public C2SSpawnIncorporealFireball(UUID playerUUID, int targetEntityId) {
|
||||||
|
this.playerUUID = playerUUID;
|
||||||
|
this.targetEntityID = targetEntityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void handle(C2SSpawnIncorporealFireball message, Supplier<NetworkEvent.Context> contextSupplier) {
|
||||||
|
NetworkEvent.Context context = contextSupplier.get();
|
||||||
|
|
||||||
|
if (context.getDirection().getReceptionSide().isServer()) {
|
||||||
|
context.enqueueWork(() -> ServerWork.handleSpawnIncorporealFireball(message));
|
||||||
|
}
|
||||||
|
context.setPacketHandled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static C2SSpawnIncorporealFireball decode(PacketBuffer buffer) {
|
||||||
|
return new C2SSpawnIncorporealFireball(buffer.readUUID(), buffer.readInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void encode(C2SSpawnIncorporealFireball message, PacketBuffer buffer) {
|
||||||
|
buffer.writeUUID(message.playerUUID);
|
||||||
|
buffer.writeInt(message.targetEntityID);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package fathertoast.specialmobs.common.network.work;
|
||||||
|
|
||||||
|
import fathertoast.specialmobs.common.entity.projectile.CorporealShiftFireballEntity;
|
||||||
|
import fathertoast.specialmobs.common.network.message.C2SSpawnIncorporealFireball;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.world.server.ServerWorld;
|
||||||
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
|
import net.minecraftforge.fml.LogicalSidedProvider;
|
||||||
|
|
||||||
|
public class ServerWork {
|
||||||
|
|
||||||
|
public static void handleSpawnIncorporealFireball(C2SSpawnIncorporealFireball message) {
|
||||||
|
MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER);
|
||||||
|
|
||||||
|
if (server == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ServerPlayerEntity player = server.getPlayerList().getPlayer(message.playerUUID);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ServerWorld world = (ServerWorld) player.level;
|
||||||
|
Entity entity = world.getEntity(message.targetEntityID);
|
||||||
|
|
||||||
|
if (!(entity instanceof LivingEntity))
|
||||||
|
return;
|
||||||
|
|
||||||
|
LivingEntity livingEntity = (LivingEntity) entity;
|
||||||
|
CorporealShiftFireballEntity fireballEntity = new CorporealShiftFireballEntity(world, player, livingEntity, player.getX(), player.getEyeY(), player.getZ());
|
||||||
|
world.addFreshEntity(fireballEntity);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package fathertoast.specialmobs.common.util;
|
||||||
|
|
||||||
|
import fathertoast.specialmobs.common.core.SpecialMobs;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.util.math.EntityRayTraceResult;
|
||||||
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class EntityUtil {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static Entity getClientMouseOver(PlayerEntity player) {
|
||||||
|
if (!player.level.isClientSide) {
|
||||||
|
SpecialMobs.LOG.error("Tried to fetch player \"mouse-over\" entity from server side. This can't be right?");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
RayTraceResult result = Minecraft.getInstance().hitResult;
|
||||||
|
|
||||||
|
if (result instanceof EntityRayTraceResult) {
|
||||||
|
return ((EntityRayTraceResult)result).getEntity();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 288 B |
Loading…
Add table
Reference in a new issue