Skip to content

Commit

Permalink
1st round of improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ANightDazingZoroark committed Apr 1, 2024
1 parent 102f441 commit 9a46a3b
Show file tree
Hide file tree
Showing 27 changed files with 237 additions and 160 deletions.
18 changes: 18 additions & 0 deletions src/main/java/anightdazingzoroark/prift/RiftUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import javax.annotation.Nullable;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class RiftUtil {
public static final double gravity = 0.08D;
Expand Down Expand Up @@ -266,4 +268,20 @@ public static boolean biomeTagMatchFromList(List<String> list, Biome biome) {
}
return false;
}

public static List<String> creatureTargets(String[] whiteList) {
return creatureTargets(whiteList, new String[]{}, false);
}

public static List<String> creatureTargets(String[] whiteList, String[] blackList, boolean useCUniversal) {
List<String> finalTargets = new ArrayList<>();
List<String> wLList = Arrays.asList(whiteList);
List<String> bLList = Arrays.asList(blackList);
List<String> baseTargetList = new ArrayList<>(Arrays.asList(GeneralConfig.universalCarnivoreTargets));
if (useCUniversal) {
baseTargetList.removeIf(bLList::contains);
finalTargets = Stream.concat(wLList.stream(), baseTargetList.stream()).collect(Collectors.toList());
}
return finalTargets;
}
}
48 changes: 33 additions & 15 deletions src/main/java/anightdazingzoroark/prift/client/ui/RiftDialMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,20 @@ else if (this.radialChoiceMenu == 0 && i == 3) {
if (user.isAttachableForWork(this.creature.getWorkstationPos())) {
drawPieArc(buffer, x, y, zLevel, radiusIn, radiusOut, s, e, 0, 0, 0, 64);
}
else drawPieArc(buffer, x, y, zLevel, radiusIn, radiusOut, s, e, 0, 0, 0, 128);
}
else drawPieArc(buffer, x, y, zLevel, radiusIn, radiusOut, s, e, 0, 0, 0, 128);
}
else {
drawPieArc(buffer, x, y, zLevel, radiusIn, radiusOut, s, e, 0, 0, 0, 128);
}
else if (this.radialChoiceMenu == 0 && this.creature.isUsingWorkstation() && (i == 1 || i == 4)) drawPieArc(buffer, x, y, zLevel, radiusIn, radiusOut, s, e, 0, 0, 0, 64);
else if (this.radialChoiceMenu == 2 && this.creature.isUsingWorkstation() && i != 0 && i != 4) drawPieArc(buffer, x, y, zLevel, radiusIn, radiusOut, s, e, 0, 0, 0, 64);
else drawPieArc(buffer, x, y, zLevel, radiusIn, radiusOut, s, e, 0, 0, 0, 128);
}

//lock mouse position
double scaledX = Mouse.getX() - (mc.displayWidth / 2.0f);
double scaledY = Mouse.getY() - (mc.displayHeight / 2.0f);
double distance = Math.sqrt(scaledX * scaledX + scaledY * scaledY);
double radius = 90.0 * (mc.displayWidth / width);
double radius = 90.0 * ((double) mc.displayWidth / width);
if (distance > radius) {
double fixedX = scaledX * radius / distance;
double fixedY = scaledY * radius / distance;
Expand Down Expand Up @@ -215,6 +216,8 @@ else if (i == 4 && this.radialChoiceMenu == 2) {
}
}
}
if (this.radialChoiceMenu == 0 && this.creature.isUsingWorkstation() && (i == 1 || i == 4)) radialString = "["+radialString+"]";
if (this.radialChoiceMenu == 2 && this.creature.isUsingWorkstation() && i != 0 && i != 4) radialString = "["+radialString+"]";

float angle1 = ((i / (float) numItems) + 0.25f) * 2 * (float) Math.PI;
float posX = x + 75 + itemRadius * (float) Math.cos(angle1) - (float)(this.fontRenderer.getStringWidth(radialString) / 2);
Expand Down Expand Up @@ -242,6 +245,15 @@ else if (this.radialChoiceMenu == 0 && this.creature.isBaby() && this.selectedIt
else if (this.radialChoiceMenu == 1 && this.creature.isUsingWorkstation() && this.selectedItem == 4) {
this.drawHoveringText(I18n.format("radial.note.too_busy"), mouseX, mouseY);
}
else if (this.radialChoiceMenu == 0 && this.creature.isUsingWorkstation() && this.selectedItem == 1) {
this.drawHoveringText(I18n.format("radial.note.too_busy"), mouseX, mouseY);
}
else if (this.radialChoiceMenu == 0 && this.creature.isUsingWorkstation() && this.selectedItem == 4) {
this.drawHoveringText(I18n.format("radial.note.too_busy"), mouseX, mouseY);
}
else if (this.radialChoiceMenu == 2 && this.creature.isUsingWorkstation() && this.selectedItem != 0 && this.selectedItem != 4) {
this.drawHoveringText(I18n.format("radial.note.too_busy"), mouseX, mouseY);
}
else if (this.radialChoiceMenu == 0 && this.selectedItem == 3) {
if (this.creature instanceof ILeadWorkstationUser) {
ILeadWorkstationUser user = (ILeadWorkstationUser) this.creature;
Expand Down Expand Up @@ -301,7 +313,7 @@ protected void mouseReleased(int mouseX, int mouseY, int state) {
RiftMessages.WRAPPER.sendToServer(new RiftOpenInventoryFromMenu(this.creature.getEntityId()));
this.mc.player.closeScreen();
}
else if (selectedItem == 1) {
else if (selectedItem == 1 && !this.creature.isUsingWorkstation()) {
this.choices = getState();
this.radialChoiceMenu = 1;
}
Expand Down Expand Up @@ -340,7 +352,7 @@ else if (selectedItem == 3) {
}
}
}
else if (selectedItem == 4 && !this.creature.isBaby()) {
else if (selectedItem == 4 && !this.creature.isBaby() && !this.creature.isUsingWorkstation()) {
this.choices = getBehavior();
this.radialChoiceMenu = 3;
}
Expand Down Expand Up @@ -373,19 +385,25 @@ else if (selectedItem == 4 && !this.creature.isUsingWorkstation()) {
this.radialChoiceMenu = 0;
}
else if (selectedItem == 1) {
ClientProxy.popupFromRadial = PopupFromRadial.CHANGE_NAME;
RiftMessages.WRAPPER.sendToServer(new RiftOpenPopupFromRadial(this.creature));
this.mc.player.closeScreen();
if (!this.creature.isUsingWorkstation()) {
ClientProxy.popupFromRadial = PopupFromRadial.CHANGE_NAME;
RiftMessages.WRAPPER.sendToServer(new RiftOpenPopupFromRadial(this.creature));
this.mc.player.closeScreen();
}
}
else if (selectedItem == 2) {
ClientProxy.popupFromRadial = PopupFromRadial.SET_HOME;
RiftMessages.WRAPPER.sendToServer(new RiftChangeHomePosFromMenu(this.creature, !this.creature.getHasHomePos()));
this.mc.player.closeScreen();
if (!this.creature.isUsingWorkstation()) {
ClientProxy.popupFromRadial = PopupFromRadial.SET_HOME;
RiftMessages.WRAPPER.sendToServer(new RiftChangeHomePosFromMenu(this.creature, !this.creature.getHasHomePos()));
this.mc.player.closeScreen();
}
}
else if (selectedItem == 3 && !this.creature.isBaby()) {
ClientProxy.popupFromRadial = PopupFromRadial.UNCLAIM;
RiftMessages.WRAPPER.sendToServer(new RiftOpenPopupFromRadial(this.creature));
this.mc.player.closeScreen();
if (!this.creature.isUsingWorkstation()) {
ClientProxy.popupFromRadial = PopupFromRadial.UNCLAIM;
RiftMessages.WRAPPER.sendToServer(new RiftOpenPopupFromRadial(this.creature));
this.mc.player.closeScreen();
}
}
else if (selectedItem == 4) {
RiftMessages.WRAPPER.sendToServer(new RiftSetWorkstation(this.creature, !this.creature.isUsingWorkstation()));
Expand Down
26 changes: 21 additions & 5 deletions src/main/java/anightdazingzoroark/prift/config/GeneralConfig.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package anightdazingzoroark.prift.config;

import anightdazingzoroark.prift.RiftInitialize;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.Loader;

public class GeneralConfig extends RiftConfig {
//general
Expand Down Expand Up @@ -32,9 +34,10 @@ public class GeneralConfig extends RiftConfig {
//spawning
public static String[] universalSpawnBlocks = {"minecraft:grass:0", "minecraft:dirt:-1", "minecraft:gravel:0", "minecraft:sand:-1", "minecraft:stone:-1"};

//mystical mechanics integration
//mod integration
public static boolean mmIntegration = true;
public static String[] lpcUsers = {"prift:stegosaurus", "prift:triceratops", "prift:utahraptor", "prift:parasaurolophus"};
public static boolean pyrotechIntegration = true;
public static boolean simpleDiffIntegration = true;

//debug
public static boolean quickEggHatch = false;
Expand Down Expand Up @@ -76,11 +79,24 @@ public void init() {
levelingRadisIncrement = config.getInt("Level increment based on distance from (0, 0)", "Creature Leveling", 10, 0, 69420666, "Level increment based on distance from (0, 0). This makes it so that the farther you are from the center, the higher the levels of wild creatures are.");
difficultyIncrement = config.getStringList("Level increment based on difficulty", "Creature Leveling", new String[]{"EASY:0", "NORMAL:5", "HARD:5"}, "Level increment based on the difficulty setting of the world. Only the number may be edited, changing the names can cause crashes. Note that the numbers are additive, so if Easy, Normal, and Hard are set to 5, the increment will be 15. Changing the order of the strings may also cause a crash.");

//mm integration
mmIntegration = config.getBoolean("Activate Mystical Mechanics Integration", "Mystical Mechanics Integration", true, "Whether or not additional features will be turned on if Better With Mods is detected in the mods folder");
lpcUsers = config.getStringList("Lead Powered Crank users", "Mystical Mechanics Integration", new String[]{"prift:stegosaurus", "prift:triceratops", "prift:utahraptor", "prift:parasaurolophus"}, "Mobs that can use the Lead Powered Crank (only works on creatures from Prehistoric Rift)");
//mod integration
mmIntegration = config.getBoolean("Activate Mystical Mechanics Integration", "Mod Integration", true, "Whether or not additional features will be turned on if Mystical Mechanics is detected in the mods folder");
pyrotechIntegration = config.getBoolean("Activate Pyrotech Integration", "Mod Integration", true, "Whether or not additional features will be turned on if Pyrotech is detected in the mods folder");
simpleDiffIntegration = config.getBoolean("Activate Simple Difficulty Integration", "Mod Integration", true, "Whether or not additional features will be turned on if Simple Difficulty is detected in the mods folder");

//debug
quickEggHatch = config.getBoolean("All eggs hatch quickly", "Debug", false, "Turning this on makes all eggs hatch within 5 seconds. Mainly here for testing purposes, idk i could have made this a gamerule or smth");
}

public static boolean canUseMM() {
return mmIntegration && Loader.isModLoaded(RiftInitialize.MYSTICAL_MECHANICS_MOD_ID);
}

public static boolean canUsePyrotech() {
return pyrotechIntegration && Loader.isModLoaded(RiftInitialize.PYROTECH_MOD_ID);
}

public static boolean canUseSimpleDiff() {
return simpleDiffIntegration && Loader.isModLoaded(RiftInitialize.SIMPLE_DIFFICULTY_MOD_ID);
}
}
52 changes: 40 additions & 12 deletions src/main/java/anightdazingzoroark/prift/server/ServerEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import anightdazingzoroark.prift.server.entity.largeWeapons.RiftCatapult;
import anightdazingzoroark.prift.server.entity.largeWeapons.RiftLargeWeapon;
import anightdazingzoroark.prift.server.entity.largeWeapons.RiftMortar;
import anightdazingzoroark.prift.server.enums.TameStatusType;
import anightdazingzoroark.prift.server.items.RiftItems;
import anightdazingzoroark.prift.server.message.RiftManageCanUseControl;
import anightdazingzoroark.prift.server.message.RiftMessages;
Expand All @@ -22,16 +23,15 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.*;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.event.ClickEvent;
Expand Down Expand Up @@ -200,6 +200,7 @@ public boolean apply(@Nullable RiftCreature input) {
if (workstationUser.isWorkstation(event.getPos())) {
event.setCanceled(true);
creature.setUseWorkstation(event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
creature.setTameStatus(TameStatusType.STAND);
event.getEntityPlayer().sendStatusMessage(new TextComponentTranslation("action.set_creature_workstation_success"), false);
}
else event.getEntityPlayer().sendStatusMessage(new TextComponentTranslation("action.set_creature_workstation_fail"), false);
Expand Down Expand Up @@ -340,21 +341,36 @@ public void noDamageWhenDismounting(LivingFallEvent event) {
}
}

//to reduce potential lag, mobs killed by wild creatures will not drop items
@SubscribeEvent
public void stopMobDrops(LivingDropsEvent event) {
public void manageDropItems(LivingDropsEvent event) {
//to reduce potential lag, mobs killed by wild creatures will not drop items
if (!GeneralConfig.canDropFromCreatureKill) {
if (event.getSource().getTrueSource() instanceof RiftCreature) {
RiftCreature attacker = (RiftCreature) event.getSource().getTrueSource();
Entity attacked = event.getEntity();
if (!attacker.isTamed()) {
if (attacked instanceof EntityTameable) {
if (!(((EntityTameable) attacked).isTamed())) {
event.setCanceled(true);
}
if (!(((EntityTameable) attacked).isTamed())) event.setCanceled(true);
}
else if (!(attacked instanceof EntityPlayer)) {
event.setCanceled(true);
else if (!(attacked instanceof EntityPlayer)) event.setCanceled(true);
}
}
}

//make it so that items dropped by mobs killed by creatures will go to the inventory of its killer
if (event.getSource().getImmediateSource() instanceof RiftCreature) {
RiftCreature attacker = (RiftCreature) event.getSource().getImmediateSource();
if (attacker.isTamed()) {
event.setCanceled(true);
for (EntityItem entityItem : event.getDrops()) {
ItemStack collected = attacker.creatureInventory.addItem(entityItem.getItem());
//if inventory is full drop the item on the floor
if (!collected.isEmpty()) {
BlockPos vicPos = event.getEntityLiving().getPosition();
EntityItem item = new EntityItem(attacker.getEntityWorld());
item.setItem(collected);
item.setPosition(vicPos.getX(), vicPos.getY(), vicPos.getZ());
attacker.getEntityWorld().spawnEntity(item);
}
}
}
Expand All @@ -367,7 +383,19 @@ public void onSetTarget(LivingSetAttackTargetEvent event) {
if (event.getTarget() instanceof EntityPlayer) {
if (event.getTarget().isRiding()) {
if (event.getTarget().getRidingEntity() instanceof RiftCreature) {
((EntityLiving)event.getEntityLiving()).setAttackTarget((RiftCreature)event.getTarget().getRidingEntity());
RiftCreature creatureRidden = (RiftCreature) event.getTarget().getRidingEntity();
EntityLiving entityLiving = (EntityLiving) event.getEntityLiving();
if (entityLiving instanceof RiftCreature) {
RiftCreature creatureAttacker = (RiftCreature) entityLiving;

if (!creatureAttacker.getTargetList().isEmpty()) {
if (creatureAttacker.getTargetList().contains(EntityList.getKey(creatureRidden).toString())) {
creatureAttacker.setAttackTarget(creatureRidden);
}
else creatureAttacker.setAttackTarget(null);
}
}
else entityLiving.setAttackTarget((RiftCreature)event.getTarget().getRidingEntity());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import anightdazingzoroark.prift.RiftInitialize;
import anightdazingzoroark.prift.compat.simpledifficulty.ModifierDimetrodon;
import anightdazingzoroark.prift.config.GeneralConfig;
import anightdazingzoroark.prift.server.blocks.RiftBlocks;
import anightdazingzoroark.prift.server.entity.creature.RiftCreature;
import anightdazingzoroark.prift.server.entity.RiftEntities;
Expand Down Expand Up @@ -49,7 +50,7 @@ public void preInit(FMLPreInitializationEvent e) {
MinecraftForge.EVENT_BUS.register(new RiftItems());
MinecraftForge.EVENT_BUS.register(new RiftBlocks());
RiftEntities.registerEntities();
if (Loader.isModLoaded(RiftInitialize.SIMPLE_DIFFICULTY_MOD_ID)) loadTemperatureRegistry();
if (GeneralConfig.canUseSimpleDiff()) loadTemperatureRegistry();
}

public void init(FMLInitializationEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class RiftBlocks {
public static final List<ItemBlock> ITEM_BLOCKS = new ArrayList<>();

public static void registerBlocks() {
if (Loader.isModLoaded(RiftInitialize.MYSTICAL_MECHANICS_MOD_ID) && GeneralConfig.mmIntegration) RiftMMBlocks.registerMMBlocks();
if (GeneralConfig.canUseMM()) RiftMMBlocks.registerMMBlocks();
}

public static Block registerBlock(Block block, String registryName, boolean includeItem) {
Expand Down
Loading

0 comments on commit 9a46a3b

Please sign in to comment.