Skip to content

Commit

Permalink
final before testing in obf env
Browse files Browse the repository at this point in the history
  • Loading branch information
ANightDazingZoroark committed Jul 2, 2024
1 parent f06c83c commit d3c49e4
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 92 deletions.
55 changes: 55 additions & 0 deletions src/main/java/anightdazingzoroark/prift/client/ClientEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

import anightdazingzoroark.prift.RiftInitialize;
import anightdazingzoroark.prift.server.ServerProxy;
import anightdazingzoroark.prift.server.entity.RiftEntityProperties;
import anightdazingzoroark.prift.server.entity.creature.Anomalocaris;
import anightdazingzoroark.prift.server.entity.creature.RiftCreature;
import anightdazingzoroark.prift.server.entity.largeWeapons.RiftLargeWeapon;
import anightdazingzoroark.prift.server.message.RiftMessages;
import anightdazingzoroark.prift.server.message.RiftOpenInventoryFromMenu;
import anightdazingzoroark.prift.server.message.RiftOpenWeaponInventory;
import net.ilexiconn.llibrary.server.entity.EntityPropertiesHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.client.event.RenderPlayerEvent;
Expand Down Expand Up @@ -39,6 +42,58 @@ public void onEntityMount(EntityMountEvent event) {
}
}

//make sure players cant move when trapped
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public void noMoveWhileTrapped(InputEvent.KeyInputEvent event) {
GameSettings settings = Minecraft.getMinecraft().gameSettings;
EntityPlayer player = Minecraft.getMinecraft().player;
RiftEntityProperties properties = EntityPropertiesHandler.INSTANCE.getProperties(player, RiftEntityProperties.class);

if (properties.isCaptured || properties.isTiedByBola) {
if (settings.keyBindForward.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindForward.getKeyCode(), false);
}
if (settings.keyBindBack.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindBack.getKeyCode(), false);
}
if (settings.keyBindLeft.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindLeft.getKeyCode(), false);
}
if (settings.keyBindRight.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindRight.getKeyCode(), false);
}
if (settings.keyBindJump.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindJump.getKeyCode(), false);
}
}
}

//for stopping creatures from being able to be controlled in water when they got no energy
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public void stopControlledMoveInWater(InputEvent.KeyInputEvent event) {
GameSettings settings = Minecraft.getMinecraft().gameSettings;
EntityPlayer player = Minecraft.getMinecraft().player;

if (player.getRidingEntity() instanceof RiftCreature) {
RiftCreature creature = (RiftCreature) player.getRidingEntity();

if (creature.isInWater() && creature.getEnergy() == 0) {
if (settings.keyBindForward.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindForward.getKeyCode(), false);
}
else if (settings.keyBindBack.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindBack.getKeyCode(), false);
}
else if (settings.keyBindLeft.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindLeft.getKeyCode(), false);
}
else if (settings.keyBindRight.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindRight.getKeyCode(), false);
}
}
}
}

//open creature inventory while riding
@SubscribeEvent
public void openInvWhileRiding(GuiOpenEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

Expand Down Expand Up @@ -148,6 +150,12 @@ else if (id == GUI_SEMI_MANUAL_HAMMERER) {
return null;
}

@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void registerModels(ModelRegistryEvent event) {
FluidRenderer.registerRenderers();
}

public void set3rdPersonView(int view) {
thirdPersonView = view;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void register(IModRegistry registry) {

if (GeneralConfig.canUsePyrotech() && ModPyrotechConfig.MODULES.get(ModuleTechBloomery.MODULE_ID)) {
registry.addRecipes(this.semiManualHammererWrappers(), smHammererCat);
registry.addRecipeClickArea(RiftSemiManualHammererMenu.class, 74, 33, 21, 14, smHammererCat);
registry.addRecipeClickArea(RiftSemiManualHammererMenu.class, 58, 33, 21, 14, smHammererCat);
registry.addRecipeCatalyst(new ItemStack(RiftMMItems.SEMI_MANUAL_HAMMERER), smHammererCat);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public RiftJEISMHammererWrapper(BloomeryRecipeBase<?> recipe) {

@Override
public void getIngredients(IIngredients iIngredients) {
iIngredients.setInput(VanillaTypes.ITEM, recipe.getOutputBloom());
ItemStack newOutput = recipe.getOutput().copy();
newOutput.setCount(12);
ItemStack newSlagOutput = recipe.getSlagItemStack().copy();
newSlagOutput.setCount(2);
ItemStack failItem = recipe.getFailureItems()[0].getItemStack();
failItem.setCount(2);
iIngredients.setInput(VanillaTypes.ITEM, this.recipe.getOutputBloom());
ItemStack newOutput = this.recipe.getOutput().copy();
newOutput.setCount(this.recipe instanceof BloomeryRecipe ? 12 : 36);
ItemStack newSlagOutput = this.recipe.getSlagItemStack().copy();
newSlagOutput.setCount(this.recipe instanceof BloomeryRecipe ? 2 : 6);
ItemStack failItem = this.recipe.getFailureItems()[0].getItemStack();
failItem.setCount(this.recipe instanceof BloomeryRecipe ? 2 : 6);
iIngredients.setOutputs(VanillaTypes.ITEM, Arrays.asList(new ItemStack[]{newOutput, newSlagOutput, failItem}));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ public SemiManualHammererContainer(TileEntitySemiManualHammerer semiManualHammer

//extractor inventory
//item
this.addSlotToContainer(new Slot(semiManualHammerer, 0, 27, 36));
this.addSlotToContainer(new Slot(semiManualHammerer, 0, 27, 36) {
@Override
public boolean isItemValid(@Nonnull ItemStack stack) {
return stack.getItem() instanceof ItemBlock && ((ItemBlock)stack.getItem()).getBlock() instanceof BlockBloom;
}
});
this.addSlotToContainer(new Slot(semiManualHammerer, 1, 97, 36) {
@Override
public boolean isItemValid(@Nonnull ItemStack stack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void update() {
}
else {
if (!this.getTopTEntity().getMustBeReset() && !this.canDoResetAnim()) {
boolean outputUsability = (this.getOutpuItem().isEmpty() || ((SemiManualExtruderRecipe)this.getTopTEntity().getCurrentRecipe()).output.apply(this.getOutpuItem())) && this.getOutpuItem().getCount() + ((SemiManualExtruderRecipe)this.getTopTEntity().getCurrentRecipe()).output.matchingStacks[0].getCount() < this.getOutpuItem().getMaxStackSize();
boolean outputUsability = (this.getOutpuItem().isEmpty() || ((SemiManualExtruderRecipe)this.getTopTEntity().getCurrentRecipe()).output.apply(this.getOutpuItem())) && this.getOutpuItem().getCount() + ((SemiManualExtruderRecipe)this.getTopTEntity().getCurrentRecipe()).output.matchingStacks[0].getCount() <= this.getOutpuItem().getMaxStackSize();
if (outputUsability) {
if (this.getTopTEntity().getTimeHeld() < this.getTopTEntity().getMaxRecipeTime()) {
this.getTopTEntity().setTimeHeld(this.getTopTEntity().getTimeHeld() + 1);
Expand Down Expand Up @@ -79,9 +79,7 @@ public void setRotation(float value) {
}

public ItemStack getOutpuItem() {
IItemHandler itemHandler = this.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (itemHandler != null) return itemHandler.getStackInSlot(1);
return null;
return this.getStackInSlot(1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import com.codetaylor.mc.pyrotech.modules.tech.bloomery.ModuleTechBloomery;
import com.codetaylor.mc.pyrotech.modules.tech.bloomery.block.BlockBloom;
import com.codetaylor.mc.pyrotech.modules.tech.bloomery.recipe.BloomAnvilRecipe;
import com.codetaylor.mc.pyrotech.modules.tech.bloomery.recipe.BloomeryRecipe;
import com.codetaylor.mc.pyrotech.modules.tech.bloomery.recipe.WitherForgeRecipe;
import net.minecraft.init.Items;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
Expand Down Expand Up @@ -45,7 +47,9 @@ else if (ModuleTechBloomery.Registries.WITHER_FORGE_RECIPE.getValue(new Resource
}
else {
if (!hammerer.getMustBeReset() && !this.canDoResetAnim()) {
boolean outputFull = this.getStackInSlot(1).getCount() + 12 < this.getStackInSlot(1).getMaxStackSize() && this.getStackInSlot(2).getCount() + 2 < this.getStackInSlot(2).getMaxStackSize() && this.getStackInSlot(3).getCount() + 2 < this.getStackInSlot(3).getMaxStackSize();
int mainAmnt = hammerer.getHammererRecipe() instanceof BloomeryRecipe ? 12 : 36;
int exAmnt = hammerer.getHammererRecipe() instanceof BloomeryRecipe ? 2 : 6;
boolean outputFull = this.getStackInSlot(1).getCount() + mainAmnt <= this.getStackInSlot(1).getMaxStackSize() && this.getStackInSlot(2).getCount() + exAmnt <= this.getStackInSlot(2).getMaxStackSize() && this.getStackInSlot(3).getCount() + exAmnt <= this.getStackInSlot(3).getMaxStackSize();
boolean outputOneUsed = this.getStackInSlot(1).isEmpty() || Ingredient.fromStacks(BloomAnvilRecipe.getRecipe(this.getInputItem(), AnvilRecipe.EnumTier.OBSIDIAN, AnvilRecipe.EnumType.HAMMER).getOutput()).apply(this.getStackInSlot(1));
boolean outputTwoUsed = this.getStackInSlot(2).isEmpty() || Ingredient.fromStacks(hammerer.getHammererRecipe().getSlagItemStack()).apply(this.getStackInSlot(2));
boolean outputThreeUsed = this.getStackInSlot(3).isEmpty() || Ingredient.fromStacks(hammerer.getHammererRecipe().getFailureItems()[0].getItemStack()).apply(this.getStackInSlot(3));
Expand All @@ -57,15 +61,15 @@ else if (ModuleTechBloomery.Registries.WITHER_FORGE_RECIPE.getValue(new Resource
}
else {
ItemStack outputStack = hammerer.getHammererRecipe().getOutput().copy();
outputStack.setCount(12);
outputStack.setCount(mainAmnt);
this.insertItemToSlot(1, outputStack);

ItemStack outputSlagStack = hammerer.getHammererRecipe().getSlagItemStack().copy();
outputSlagStack.setCount(2);
outputSlagStack.setCount(exAmnt);
this.insertItemToSlot(2, outputSlagStack);

ItemStack failItem = hammerer.getHammererRecipe().getFailureItems()[0].getItemStack();
failItem.setCount(2);
failItem.setCount(exAmnt);
this.insertItemToSlot(3, failItem);

this.getInputItem().shrink(1);
Expand All @@ -91,6 +95,12 @@ public int[] getSlotsForFace(EnumFacing side) {
return new int[]{0};
}

@Override
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
if (index == 0) return itemStackIn.getItem() instanceof ItemBlock && ((ItemBlock)itemStackIn.getItem()).getBlock() instanceof BlockBloom;
return this.isItemValidForSlot(index, itemStackIn);
}

@Override
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
if (index != 0) return direction == EnumFacing.DOWN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void update() {
}
else {
if (!this.getTopTEntity().getMustBeReset() && !this.canDoResetAnim()) {
boolean outputUsability = (this.getOutpuItem().isEmpty() || ((SemiManualPresserRecipe)this.getTopTEntity().getCurrentRecipe()).output.apply(this.getOutpuItem())) && this.getOutpuItem().getCount() + ((SemiManualPresserRecipe)this.getTopTEntity().getCurrentRecipe()).output.matchingStacks[0].getCount() < this.getOutpuItem().getMaxStackSize();
boolean outputUsability = (this.getOutpuItem().isEmpty() || ((SemiManualPresserRecipe)this.getTopTEntity().getCurrentRecipe()).output.apply(this.getOutpuItem())) && this.getOutpuItem().getCount() + ((SemiManualPresserRecipe)this.getTopTEntity().getCurrentRecipe()).output.matchingStacks[0].getCount() <= this.getOutpuItem().getMaxStackSize();
if (outputUsability) {
if (this.getTopTEntity().getTimeHeld() < this.getTopTEntity().getMaxRecipeTime()) {
this.getTopTEntity().setTimeHeld(this.getTopTEntity().getTimeHeld() + 1);
Expand All @@ -54,8 +54,6 @@ public void update() {
}

public ItemStack getOutpuItem() {
IItemHandler itemHandler = this.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (itemHandler != null) return itemHandler.getStackInSlot(1);
return null;
return this.getStackInSlot(1);
}
}
60 changes: 0 additions & 60 deletions src/main/java/anightdazingzoroark/prift/server/ServerEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import anightdazingzoroark.prift.client.RiftControls;
import anightdazingzoroark.prift.compat.mysticalmechanics.blocks.BlockSemiManualBaseTop;
import anightdazingzoroark.prift.config.GeneralConfig;
import anightdazingzoroark.prift.config.RiftConfig;
import anightdazingzoroark.prift.server.entity.PlayerJournalProgress;
import anightdazingzoroark.prift.server.entity.creature.*;
import anightdazingzoroark.prift.server.entity.RiftEntityProperties;
Expand All @@ -15,7 +14,6 @@
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.MobSize;
import anightdazingzoroark.prift.server.enums.TameStatusType;
import anightdazingzoroark.prift.server.items.RiftItems;
import anightdazingzoroark.prift.server.message.RiftManageCanUseControl;
Expand All @@ -26,17 +24,13 @@
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.client.settings.KeyBinding;
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.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
Expand All @@ -48,9 +42,7 @@
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.ExplosionEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;

import javax.annotation.Nullable;
Expand All @@ -68,32 +60,6 @@ public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) {
}
}

//make sure players cant move when trapped
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public void noMoveWhileTrapped(InputEvent.KeyInputEvent event) {
GameSettings settings = Minecraft.getMinecraft().gameSettings;
EntityPlayer player = Minecraft.getMinecraft().player;
RiftEntityProperties properties = EntityPropertiesHandler.INSTANCE.getProperties(player, RiftEntityProperties.class);

if (properties.isCaptured || properties.isTiedByBola) {
if (settings.keyBindForward.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindForward.getKeyCode(), false);
}
if (settings.keyBindBack.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindBack.getKeyCode(), false);
}
if (settings.keyBindLeft.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindLeft.getKeyCode(), false);
}
if (settings.keyBindRight.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindRight.getKeyCode(), false);
}
if (settings.keyBindJump.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindJump.getKeyCode(), false);
}
}
}

@SubscribeEvent
public void noAttackWhileRiding(AttackEntityEvent event) {
//prevent players from attackin while ridin
Expand Down Expand Up @@ -292,32 +258,6 @@ public void onBlockBreak(BlockEvent.HarvestDropsEvent event) {
}
}

//for stopping creatures from being able to be controlled in water when they got no energy
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public void stopControlledMoveInWater(InputEvent.KeyInputEvent event) {
GameSettings settings = Minecraft.getMinecraft().gameSettings;
EntityPlayer player = Minecraft.getMinecraft().player;

if (player.getRidingEntity() instanceof RiftCreature) {
RiftCreature creature = (RiftCreature) player.getRidingEntity();

if (creature.isInWater() && creature.getEnergy() == 0) {
if (settings.keyBindForward.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindForward.getKeyCode(), false);
}
else if (settings.keyBindBack.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindBack.getKeyCode(), false);
}
else if (settings.keyBindLeft.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindLeft.getKeyCode(), false);
}
else if (settings.keyBindRight.isKeyDown()) {
KeyBinding.setKeyBindState(settings.keyBindRight.getKeyCode(), false);
}
}
}
}

//i forgor what tf this does :skull:
//probably best if it doesnt get deleted
@SubscribeEvent
Expand Down
Loading

0 comments on commit d3c49e4

Please sign in to comment.