Skip to content

Commit

Permalink
Fix white spaces and some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
maruohon committed Jun 24, 2017
1 parent 6649659 commit 5ad68de
Show file tree
Hide file tree
Showing 28 changed files with 655 additions and 742 deletions.
6 changes: 2 additions & 4 deletions src/main/java/baubles/api/BaubleType.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public enum BaubleType {
HEAD(4),
BODY(5),
CHARM(6);

int[] validSlots;

private BaubleType(int ... validSlots) {
this.validSlots = validSlots;
}

public boolean hasSlot(int slot) {
for (int s:validSlots) {
if (s == slot) return true;
Expand All @@ -25,6 +25,4 @@ public boolean hasSlot(int slot) {
public int[] getValidSlots() {
return validSlots;
}


}
8 changes: 3 additions & 5 deletions src/main/java/baubles/api/BaublesApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
/**
* @author Azanor
*/
public class BaublesApi
{

public class BaublesApi
{
/**
* Retrieves the baubles inventory capability handler for the supplied player
*/
Expand All @@ -20,7 +19,7 @@ public static IBaublesItemHandler getBaublesHandler(EntityPlayer player)
IBaublesItemHandler handler = player.getCapability(BaublesCapabilities.CAPABILITY_BAUBLES, null);
handler.setPlayer(player);
return handler;
}
}

/**
* Retrieves the baubles capability handler wrapped as a IInventory for the supplied player
Expand All @@ -32,5 +31,4 @@ public static IInventory getBaubles(EntityPlayer player)
handler.setPlayer(player);
return new BaublesInventoryWrapper(handler, player);
}

}
13 changes: 6 additions & 7 deletions src/main/java/baubles/api/IBauble.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@
*/

public interface IBauble {

/**
* This method return the type of bauble this is.
* Type is used to determine the slots it can go into.
*/
public BaubleType getBaubleType(ItemStack itemstack);

/**
* This method is called once per tick if the bauble is being worn by a player
*/
public default void onWornTick(ItemStack itemstack, EntityLivingBase player) {
}

/**
* This method is called when the bauble is equipped by a player
*/
public default void onEquipped(ItemStack itemstack, EntityLivingBase player) {
}

/**
* This method is called when the bauble is unequipped by a player
*/
Expand All @@ -42,14 +42,14 @@ public default void onUnequipped(ItemStack itemstack, EntityLivingBase player) {
public default boolean canEquip(ItemStack itemstack, EntityLivingBase player) {
return true;
}

/**
* Can this bauble be removed from a bauble slot
*/
public default boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
return true;
}

/**
* Will bauble automatically sync to client if a change is detected in its NBT or damage values?
* Default is off, so override and set to true if you want to auto sync.
Expand All @@ -58,5 +58,4 @@ public default boolean canUnequip(ItemStack itemstack, EntityLivingBase player)
public default boolean willAutoSync(ItemStack itemstack, EntityLivingBase player) {
return false;
}

}
35 changes: 15 additions & 20 deletions src/main/java/baubles/api/cap/BaublesCapabilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,20 @@
import net.minecraftforge.common.capabilities.CapabilityInject;

public class BaublesCapabilities {

/**
* Access to the baubles capability.
*/
@CapabilityInject(IBaublesItemHandler.class)
public static final Capability<IBaublesItemHandler> CAPABILITY_BAUBLES = null;

public static class CapabilityBaubles<T extends IBaublesItemHandler> implements IStorage<IBaublesItemHandler> {

@Override
public NBTBase writeNBT (Capability<IBaublesItemHandler> capability, IBaublesItemHandler instance, EnumFacing side) {

return null;
}

@Override
public void readNBT (Capability<IBaublesItemHandler> capability, IBaublesItemHandler instance, EnumFacing side, NBTBase nbt) {

}
}

* Access to the baubles capability.
*/
@CapabilityInject(IBaublesItemHandler.class)
public static final Capability<IBaublesItemHandler> CAPABILITY_BAUBLES = null;

public static class CapabilityBaubles<T extends IBaublesItemHandler> implements IStorage<IBaublesItemHandler> {

@Override
public NBTBase writeNBT (Capability<IBaublesItemHandler> capability, IBaublesItemHandler instance, EnumFacing side) {
return null;
}

@Override
public void readNBT (Capability<IBaublesItemHandler> capability, IBaublesItemHandler instance, EnumFacing side, NBTBase nbt){ }
}
}
29 changes: 14 additions & 15 deletions src/main/java/baubles/api/cap/BaublesContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public class BaublesContainer extends ItemStackHandler implements IBaublesItemHa
private boolean[] changed = new boolean[BAUBLE_SLOTS];
private boolean blockEvents=false;
private EntityLivingBase player;

public BaublesContainer()
{
super(BAUBLE_SLOTS);
}
{
super(BAUBLE_SLOTS);
}

@Override
public void setSize(int size)
{
{
if (size<BAUBLE_SLOTS) size = BAUBLE_SLOTS;
super.setSize(size);
boolean[] old = changed;
Expand All @@ -28,7 +28,7 @@ public void setSize(int size)
{
changed[i] = old[i];
}
}
}

/**
* Returns true if automation is allowed to insert the given stack (ignoring
Expand All @@ -38,10 +38,10 @@ public void setSize(int size)
public boolean isItemValidForSlot(int slot, ItemStack stack, EntityLivingBase player) {
if (stack==null || stack.isEmpty() || !(stack.getItem() instanceof IBauble) ||
!((IBauble) stack.getItem()).canEquip(stack, player))
return false;
return false;
return ((IBauble) stack.getItem()).getBaubleType(stack).hasSlot(slot);
}

@Override
public void setStackInSlot(int slot, ItemStack stack) {
if (stack==null || stack.isEmpty() || this.isItemValidForSlot(slot, stack, player)) {
Expand All @@ -54,7 +54,7 @@ public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
if (!this.isItemValidForSlot(slot, stack, player)) return stack;
return super.insertItem(slot, stack, simulate);
}

@Override
public boolean isEventBlocked() {
return blockEvents;
Expand All @@ -64,13 +64,13 @@ public boolean isEventBlocked() {
public void setEventBlock(boolean blockEvents) {
this.blockEvents = blockEvents;
}

@Override
protected void onContentsChanged(int slot)
{
{
setChanged(slot,true);
}
}

@Override
public boolean isChanged(int slot) {
if (changed==null) {
Expand All @@ -91,5 +91,4 @@ public void setChanged(int slot, boolean change) {
public void setPlayer(EntityLivingBase player) {
this.player=player;
}

}
49 changes: 24 additions & 25 deletions src/main/java/baubles/api/cap/BaublesContainerProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,30 @@
public class BaublesContainerProvider implements INBTSerializable<NBTTagCompound>, ICapabilityProvider {

private final BaublesContainer container;

public BaublesContainerProvider(BaublesContainer container) {
this.container = container;
}


public BaublesContainerProvider(BaublesContainer container) {
this.container = container;
}

@Override
public boolean hasCapability (Capability<?> capability, EnumFacing facing) {
return capability == BaublesCapabilities.CAPABILITY_BAUBLES;
}

@Override
public boolean hasCapability (Capability<?> capability, EnumFacing facing) {
return capability == BaublesCapabilities.CAPABILITY_BAUBLES;
}

@Override
@SuppressWarnings("unchecked")
public <T> T getCapability (Capability<T> capability, EnumFacing facing) {
if (capability == BaublesCapabilities.CAPABILITY_BAUBLES) return (T) this.container;
return null;
}

@Override
public NBTTagCompound serializeNBT () {
return this.container.serializeNBT();
}

@Override
public void deserializeNBT (NBTTagCompound nbt) {
this.container.deserializeNBT(nbt);
}
@SuppressWarnings("unchecked")
public <T> T getCapability (Capability<T> capability, EnumFacing facing) {
if (capability == BaublesCapabilities.CAPABILITY_BAUBLES) return (T) this.container;
return null;
}

@Override
public NBTTagCompound serializeNBT () {
return this.container.serializeNBT();
}

@Override
public void deserializeNBT (NBTTagCompound nbt) {
this.container.deserializeNBT(nbt);
}
}
5 changes: 2 additions & 3 deletions src/main/java/baubles/api/cap/IBaublesItemHandler.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package baubles.api.cap;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandlerModifiable;

public interface IBaublesItemHandler extends IItemHandlerModifiable {
public interface IBaublesItemHandler extends IItemHandlerModifiable {

public boolean isItemValidForSlot(int slot, ItemStack stack, EntityLivingBase player);

/**
Expand Down
24 changes: 10 additions & 14 deletions src/main/java/baubles/api/inv/BaublesInventoryWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
import net.minecraft.util.text.TextComponentString;

public class BaublesInventoryWrapper implements IInventory {

final IBaublesItemHandler handler;
final IBaublesItemHandler handler;
final EntityPlayer player;

public BaublesInventoryWrapper(IBaublesItemHandler handler) {
super();
this.handler = handler;
Expand Down Expand Up @@ -43,7 +42,7 @@ public ITextComponent getDisplayName() {
public int getSizeInventory() {
return handler.getSlots();
}

@Override
public boolean isEmpty() {
return false;
Expand Down Expand Up @@ -77,18 +76,18 @@ public int getInventoryStackLimit() {
}

@Override
public void markDirty() { }
public void markDirty() { }

@Override
public boolean isUsableByPlayer(EntityPlayer player) {
return true;
}

@Override
public void openInventory(EntityPlayer player) { }
public void openInventory(EntityPlayer player) { }

@Override
public void closeInventory(EntityPlayer player) { }
public void closeInventory(EntityPlayer player) { }

@Override
public boolean isItemValidForSlot(int index, ItemStack stack) {
Expand All @@ -109,13 +108,10 @@ public int getFieldCount() {
}

@Override
public void clear() {
public void clear() {
for (int i = 0; i < this.getSizeInventory(); ++i)
{
{
this.setInventorySlotContents(i, ItemStack.EMPTY);
}
}
}



}
2 changes: 0 additions & 2 deletions src/main/java/baubles/api/render/IRenderBauble.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public static void translateToChest() {
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.translate(0F, -3.2F, -0.85F);
}

}

public enum RenderType {
Expand All @@ -110,5 +109,4 @@ public enum RenderType {
*/
HEAD;
}

}
Loading

0 comments on commit 5ad68de

Please sign in to comment.