Skip to content

Commit

Permalink
Fix bugs and other stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ThexXTURBOXx committed Sep 3, 2022
1 parent 47ba941 commit 91df1c3
Show file tree
Hide file tree
Showing 44 changed files with 253 additions and 383 deletions.
44 changes: 22 additions & 22 deletions src/main/java/org/silvercatcher/reforged/ReforgedEvents.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.silvercatcher.reforged;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -34,15 +33,15 @@ public class ReforgedEvents {
public static Map<UUID, Integer> map;

static {
map = new HashMap<UUID, Integer>();
map = new HashMap<>();
}

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void customReach(MouseEvent e) {
if (e.getButton() == 0 && e.isButtonstate()) {
Minecraft mc = Minecraft.getMinecraft();
if (mc.player.inventory.getCurrentItem() != null && !mc.player.inventory.getCurrentItem().isEmpty()) {
if (!mc.player.inventory.getCurrentItem().isEmpty()) {
Item i = mc.player.inventory.getCurrentItem().getItem();
if (i instanceof ICustomReach && i instanceof ItemExtension) {
ICustomReach icr = (ICustomReach) i;
Expand Down Expand Up @@ -109,29 +108,30 @@ public void onTick(PlayerTickEvent e) {

@SubscribeEvent
public void onWorldTick(WorldTickEvent e) {
if (!e.world.isRemote) {
Iterator<Entity> iter = e.world.loadedEntityList.iterator();
while (iter.hasNext()) {
Entity en = iter.next();
if (en instanceof EntityLivingBase) {
EntityLivingBase player = (EntityLivingBase) en;
IStunProperty prop = player.getCapability(ReforgedMod.STUN_PROP, null);
if (prop != null && prop.isStunned()) {
if (!map.containsKey(player.getUniqueID()))
map.put(player.getUniqueID(), 0);
int i = map.get(player.getUniqueID());
i++;
player.motionX = 0;
player.motionY = 0;
player.motionZ = 0;
map.put(player.getUniqueID(), i);
if (map.get(player.getUniqueID()) >= 60) {
prop.setStunned(false);
map.put(player.getUniqueID(), 0);
try {
if (!e.world.isRemote) {
for (Entity en : e.world.loadedEntityList) {
if (en instanceof EntityLivingBase) {
EntityLivingBase player = (EntityLivingBase) en;
IStunProperty prop = player.getCapability(ReforgedMod.STUN_PROP, null);
if (prop != null && prop.isStunned()) {
if (!map.containsKey(player.getUniqueID()))
map.put(player.getUniqueID(), 0);
int i = map.get(player.getUniqueID());
i++;
player.motionX = 0;
player.motionY = 0;
player.motionZ = 0;
map.put(player.getUniqueID(), i);
if (map.get(player.getUniqueID()) >= 60) {
prop.setStunned(false);
map.put(player.getUniqueID(), 0);
}
}
}
}
}
} catch (Throwable ignored) {
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/silvercatcher/reforged/ReforgedMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ReforgedMod {

public static final String NAME = "Reforged";
public static final String ID = "reforged";
public static final String VERSION = "0.7.5";
public static final String VERSION = "0.7.6";
public static final String UPDATE_JSON = "https://raw.githubusercontent"
+ ".com/ThexXTURBOXx/UpdateJSONs/master/reforged.json";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public class ReforgedMonsterArmourer {
private final Random random = new Random();

private void equipZombie(EntityZombie zombie) {
if ((zombie.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND) == null
|| zombie.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND).isEmpty()) && random.nextInt(10) == 0) {
if (zombie.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND).isEmpty() && random.nextInt(10) == 0) {
Item item = randomFrom(zombieWeapons);
zombie.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(item));

Expand All @@ -49,7 +48,7 @@ public void onSpawn(EntityJoinWorldEvent event) {
public void onWorldLoad(WorldEvent.Load e) {
if (e.isCanceled() || e.getWorld().isRemote)
return;
List<Item> list = new ArrayList<Item>();
List<Item> list = new ArrayList<>();
for (Item i : ReforgedRegistry.registrationList) {
if (i instanceof IZombieEquippable) {
for (int c = 0; c < ((IZombieEquippable) i).zombieSpawnChance(); c++)
Expand All @@ -59,7 +58,7 @@ public void onWorldLoad(WorldEvent.Load e) {
if (list.isEmpty())
zombieWeapons = null;
else
zombieWeapons = list.toArray(new Item[list.size()]);
zombieWeapons = list.toArray(new Item[0]);
}

private Item randomFrom(Item[] selection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static class GlobalValues {
public static final boolean PIKE = CommonProxy.pike;
public static final boolean MACE = CommonProxy.mace;
public static final boolean DIRK = CommonProxy.dirk;
public static final boolean CANNON = CommonProxy.cannon;
//public static final boolean CANNON = CommonProxy.cannon;
}

/**
Expand Down
25 changes: 12 additions & 13 deletions src/main/java/org/silvercatcher/reforged/ReforgedRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
Expand All @@ -31,7 +29,6 @@
import org.silvercatcher.reforged.items.weapons.ItemBlowGun;
import org.silvercatcher.reforged.items.weapons.ItemBlunderbuss;
import org.silvercatcher.reforged.items.weapons.ItemBoomerang;
import org.silvercatcher.reforged.items.weapons.ItemCannon;
import org.silvercatcher.reforged.items.weapons.ItemCrossbow;
import org.silvercatcher.reforged.items.weapons.ItemDirk;
import org.silvercatcher.reforged.items.weapons.ItemDynamite;
Expand All @@ -56,8 +53,8 @@ public class ReforgedRegistry {
/**
* Every item on that list gets registered
*/
public static List<Item> registrationList = new ArrayList<Item>();
public static List<Block> registrationListBlocks = new ArrayList<Block>();
public static List<Item> registrationList = new ArrayList<>();
public static List<Block> registrationListBlocks = new ArrayList<>();

// Registry

Expand Down Expand Up @@ -197,12 +194,12 @@ public static void createItems() {
registrationList.add(ReforgedAdditions.DIAMOND_DIRK = new ItemDirk(ToolMaterial.DIAMOND));
}

if (GlobalValues.CANNON) {
/*if (GlobalValues.CANNON) {
registrationList.add(ReforgedAdditions.CANNON = new ItemCannon().setTranslationKey("cannon")
.setCreativeTab(ReforgedMod.tabReforged));
registrationList.add(ReforgedAdditions.CANNON_BALL = new Item().setTranslationKey("cannon_ball")
.setCreativeTab(ReforgedMod.tabReforged));
}
}*/
}

/**
Expand All @@ -219,22 +216,20 @@ public static void registerEntity(Class<? extends Entity> c, String name) {
/**
* Helper method for registering our EventHandler
*
* @param ReforgedEvents The instance of our EventHandler
* @param event The instance of our EventHandler
*/
public static void registerEventHandler(Object event) {
FMLCommonHandler.instance().bus().register(event);
MinecraftForge.EVENT_BUS.register(event);
}

/**
* Helper method for registering an Custom IRecipe
*
* @param name The name for the Recipe
* @param recipe The instance of the Recipe
* @param recipeclass The class of the Recipe
* @param category {@link Category#SHAPED} or {@link Category#SHAPELESS}?
*/
public static void registerIRecipe(String name, IRecipe recipe, Class<?> recipeclass, Category category) {
public static void registerIRecipe(String name, Class<?> recipeclass, Category category) {
String catString;
if (category == Category.SHAPELESS) {
catString = "after:minecraft:shapeless";
Expand All @@ -257,8 +252,10 @@ public static void registerPackets() {
packetId++, Side.SERVER);
}

/**
* Registers all blocks out of the registrationListBlocks
*/
@SubscribeEvent
/** Registers all blocks out of the registrationListBlocks */
public void registerBlocks(RegistryEvent.Register<Block> event) {
IForgeRegistry<Block> reg = event.getRegistry();
for (Block block : registrationListBlocks) {
Expand All @@ -267,8 +264,10 @@ public void registerBlocks(RegistryEvent.Register<Block> event) {
}
}

/**
* Registers all items out of the registrationList
*/
@SubscribeEvent
/** Registers all items out of the registrationList */
public void registerItems(RegistryEvent.Register<Item> event) {
IForgeRegistry<Item> reg = event.getRegistry();
// Register all Items
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
Expand All @@ -23,7 +22,7 @@ public abstract class AReforgedThrowable extends EntityThrowable {

private final String damageName;

public AReforgedThrowable(World worldIn, EntityLivingBase thrower, ItemStack stack, String damageName) {
public AReforgedThrowable(World worldIn, EntityLivingBase thrower, String damageName) {
super(worldIn, thrower);
this.damageName = damageName;
setLocationAndAngles(thrower.posX, thrower.posY + thrower.getEyeHeight(), thrower.posZ, thrower.rotationYaw,
Expand Down Expand Up @@ -137,8 +136,7 @@ protected void onImpact(RayTraceResult target) {
&& ticksExisted < 5) {
return;
}
broken = onEntityHit(target.entityHit instanceof EntityLivingBase ? target.entityHit
: target.entityHit);
broken = onEntityHit(target.entityHit);
}
if (broken)
setDead();
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/silvercatcher/reforged/api/AReloadable.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public AReloadable(String name, String shootSound, String reloadSound) {
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
return entityIn != null && entityIn.isHandActive()
&& entityIn.getActiveItemStack() == stack && stack.hasTagCompound()
&& stack.getTagCompound().getInteger(CompoundTags.TIME) < getReloadTotal()
&& CompoundTags.giveCompound(stack).getInteger(CompoundTags.TIME) < getReloadTotal()
? 1.0F : 0.0F;
}
});
Expand All @@ -62,7 +62,7 @@ public void addInformation(ItemStack stack, World worldIn, List<String> tooltip,
public abstract Item getAmmo();

@Override
public Multimap getAttributeModifiers(ItemStack stack) {
public Multimap<String, AttributeModifier> getAttributeModifiers(ItemStack stack) {
return ItemExtension.super.getAttributeModifiers(stack);
}

Expand Down Expand Up @@ -190,8 +190,8 @@ public boolean canContinueUsing(ItemStack oldStack, ItemStack newStack) {
return false;
}

int oldReloadTime = oldStack.getTagCompound().getInteger(CompoundTags.TIME);
int newReloadTime = newStack.getTagCompound().getInteger(CompoundTags.TIME);
int oldReloadTime = CompoundTags.giveCompound(oldStack).getInteger(CompoundTags.TIME);
int newReloadTime = CompoundTags.giveCompound(newStack).getInteger(CompoundTags.TIME);
if (oldReloadTime == 0 || newReloadTime == 0) // if either stack is unloaded, abort
return false;
if (oldReloadTime < getReloadTotal()) // if both stacks are reloading, we can continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public double getAttackSpeed(ItemStack stack) {
}

@Override
public Multimap getAttributeModifiers(ItemStack stack) {
public Multimap<String, AttributeModifier> getAttributeModifiers(ItemStack stack) {
return ItemExtension.super.getAttributeModifiers(stack);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ default double getAttackSpeed(ItemStack stack) {
return -2.4000000953674316D;
}

default Multimap getAttributeModifiers(ItemStack stack) {
default Multimap<String, AttributeModifier> getAttributeModifiers(ItemStack stack) {

Multimap modifiers = HashMultimap.create();
Multimap<String, AttributeModifier> modifiers = HashMultimap.create();

modifiers.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(),
new AttributeModifier(ATTACK_DAMAGE_MODIFIER_RF, "Weapon Damage", getHitDamage(stack), 0));
Expand All @@ -46,7 +46,7 @@ default DamageSource getDamage(EntityLivingBase p) {
return DamageSource.causeMobDamage(p);
}

default float getEnchantmentBonus(ItemStack stack, EntityPlayer player, Entity entity) {
default float getEnchantmentBonus(ItemStack stack, Entity entity) {

float extraDamage = 0f;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public EntityBoomerang(World worldIn) {
}

public EntityBoomerang(World worldIn, EntityLivingBase thrower, ItemStack stack) {
super(worldIn, thrower, stack, "boomerang");
super(worldIn, thrower, "boomerang");
setItemStack(stack);
setCoords(thrower.posX, thrower.posY + thrower.getEyeHeight(), thrower.posZ);
setInited();
Expand Down Expand Up @@ -71,9 +71,7 @@ public MaterialDefinition getMaterialDefinition() {
MaterialDefinition md;
try {
md = ((ItemBoomerang) getItemStack().getItem()).getMaterialDefinition();
} catch (NullPointerException e) {
md = null;
} catch (ClassCastException e) {
} catch (NullPointerException | ClassCastException e) {
md = null;
}
return md;
Expand Down Expand Up @@ -155,15 +153,13 @@ public void onUpdated() {
motionY -= (0.05D * dy);
motionZ -= (0.05D * dz);

if (isInWater()) {
if (!world.isRemote) {
if (getItemStack().getMaxDamage() - getItemStack().getItemDamage() > 0 && !creativeUse()) {
entityDropItem(getItemStack(), 0.5f);
} else if (getItemStack().getMaxDamage() - getItemStack().getItemDamage() <= 0) {
Helpers.playSound(world, this, "boomerang_break", 1.0F, 1.0F);
}
setDead();
if (isInWater() && !world.isRemote) {
if (getItemStack().getMaxDamage() - getItemStack().getItemDamage() > 0 && !creativeUse()) {
entityDropItem(getItemStack(), 0.5f);
} else if (getItemStack().getMaxDamage() - getItemStack().getItemDamage() <= 0) {
Helpers.playSound(world, this, "boomerang_break", 1.0F, 1.0F);
}
setDead();
}

// After 103 ticks, the Boomerang drops exactly where the thrower stood
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import org.silvercatcher.reforged.api.AReforgedThrowable;

Expand All @@ -13,9 +12,9 @@ public EntityBulletBlunderbuss(World worldIn) {
super(worldIn, "blunderbuss");
}

public EntityBulletBlunderbuss(World worldIn, EntityLivingBase throwerIn, ItemStack stack) {
public EntityBulletBlunderbuss(World worldIn, EntityLivingBase throwerIn) {

super(worldIn, throwerIn, stack, "blunderbuss");
super(worldIn, throwerIn, "blunderbuss");
float randomNumX = rand.nextInt(21);
float randomNumY = rand.nextInt(21);
float randomNumZ = rand.nextInt(21);
Expand All @@ -39,7 +38,7 @@ public EntityBulletBlunderbuss(World worldIn, EntityLivingBase throwerIn, ItemSt

@Override
protected float getImpactDamage(Entity target) {
return (((30 - ticksExisted) / 4) + 4f);
return (((30 - ticksExisted) / 4f) + 4f);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import org.silvercatcher.reforged.api.AReforgedThrowable;
import org.silvercatcher.reforged.proxy.CommonProxy;
Expand All @@ -14,8 +13,8 @@ public EntityBulletMusket(World worldIn) {
setNoGravity(true);
}

public EntityBulletMusket(World worldIn, EntityLivingBase throwerIn, ItemStack stack) {
super(worldIn, throwerIn, stack, "musket");
public EntityBulletMusket(World worldIn, EntityLivingBase throwerIn) {
super(worldIn, throwerIn, "musket");
setNoGravity(true);
motionX *= 5;
motionY *= 5;
Expand Down
Loading

0 comments on commit 91df1c3

Please sign in to comment.