Skip to content

Commit

Permalink
code format
Browse files Browse the repository at this point in the history
  • Loading branch information
frodare committed Sep 19, 2018
1 parent a7fb756 commit b2f87f6
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@

public class PotionDisplay extends AbstractEntityDisplay implements IDisplay {

public static final ResourceLocation INVENTORY_BACKGROUND = new ResourceLocation("textures/gui/container/inventory.png");
private final Minecraft mc;
private final Gui gui;
private int x, originX = 100;
private int y, originY = 100;

public static final ResourceLocation INVENTORY_BACKGROUND = new ResourceLocation("textures/gui/container/inventory.png");

public PotionDisplay(Minecraft mc, Gui gui) {
this.mc = mc;
this.gui = gui;
Expand Down Expand Up @@ -61,7 +60,7 @@ private void drawEffects() {

mc.renderEngine.bindTexture(INVENTORY_BACKGROUND);

for(PotionEffect potion : potions){
for (PotionEffect potion : potions) {

System.out.println(x + ", " + y);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import net.torocraft.torohud.display.BarDisplay;
import net.torocraft.torohud.display.EntityDisplay;
import net.torocraft.torohud.display.HeartsDisplay;
import net.torocraft.torohud.display.IDisplay;
import net.torocraft.torohud.display.NumericDisplay;
import net.torocraft.torohud.display.PotionDisplay;
import net.torocraft.torohud.display.IDisplay;

public class GuiEntityStatus extends Gui {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ public class MessageEntityStatsRequest implements IMessage {

public int id;

public static void init(int packetId) {
ToroHUD.NETWORK.registerMessage(Handler.class, MessageEntityStatsRequest.class, packetId, Side.SERVER);
}

public MessageEntityStatsRequest() {

}
Expand All @@ -26,6 +22,10 @@ public MessageEntityStatsRequest(int id) {
this.id = id;
}

public static void init(int packetId) {
ToroHUD.NETWORK.registerMessage(Handler.class, MessageEntityStatsRequest.class, packetId, Side.SERVER);
}

@Override
public void fromBytes(ByteBuf buf) {
id = buf.readInt();
Expand All @@ -50,7 +50,7 @@ private void work(EntityPlayerMP player, MessageEntityStatsRequest message) {
if (!(entity instanceof EntityLivingBase)) {
return;
}
EntityLivingBase entityLiving = (EntityLivingBase)entity;
EntityLivingBase entityLiving = (EntityLivingBase) entity;

MessageEntityStatsResponse reply = new MessageEntityStatsResponse(message.id, entityLiving.getActivePotionEffects());
ToroHUD.NETWORK.sendTo(reply, player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ public class MessageEntityStatsResponse implements IMessage {
private int id;
private Collection<PotionEffect> potions;

public static void init(int packetId) {
ToroHUD.NETWORK.registerMessage(Handler.class, MessageEntityStatsResponse.class, packetId, Side.CLIENT);
}

public MessageEntityStatsResponse() {

}
Expand All @@ -38,6 +34,10 @@ public MessageEntityStatsResponse(int id, Collection<PotionEffect> potions) {
this.potions = potions;
}

public static void init(int packetId) {
ToroHUD.NETWORK.registerMessage(Handler.class, MessageEntityStatsResponse.class, packetId, Side.CLIENT);
}

@Override
public void fromBytes(ByteBuf buf) {
id = buf.readInt();
Expand Down Expand Up @@ -72,18 +72,18 @@ private void writePotions(ByteBuf buf) {

public static class Handler implements IMessageHandler<MessageEntityStatsResponse, IMessage> {

@Override
public IMessage onMessage(final MessageEntityStatsResponse message, MessageContext ctx) {
Minecraft.getMinecraft().addScheduledTask(() -> work(message));
return null;
}

public static void work(MessageEntityStatsResponse message) {
POTIONS = message.potions;
for (PotionEffect p : message.potions) {
System.out.println("POTION ON CLIENT: " + p.getEffectName() + " " + p.getDuration());
}

}

@Override
public IMessage onMessage(final MessageEntityStatsResponse message, MessageContext ctx) {
Minecraft.getMinecraft().addScheduledTask(() -> work(message));
return null;
}
}
}
22 changes: 11 additions & 11 deletions src/main/java/net/torocraft/torohud/network/MessageLivingHurt.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ public class MessageLivingHurt implements IMessage {
private int id;
private float amount;

public static void init(int packetId) {
ToroHUD.NETWORK.registerMessage(Handler.class, MessageLivingHurt.class, packetId, Side.CLIENT);
}

public MessageLivingHurt() {

}
Expand All @@ -29,6 +25,10 @@ public MessageLivingHurt(int id, float amount) {
this.amount = amount;
}

public static void init(int packetId) {
ToroHUD.NETWORK.registerMessage(Handler.class, MessageLivingHurt.class, packetId, Side.CLIENT);
}

@Override
public void fromBytes(ByteBuf buf) {
id = buf.readInt();
Expand All @@ -43,18 +43,18 @@ public void toBytes(ByteBuf buf) {

public static class Handler implements IMessageHandler<MessageLivingHurt, IMessage> {

@Override
public IMessage onMessage(final MessageLivingHurt message, MessageContext ctx) {
Minecraft.getMinecraft().addScheduledTask(() -> work(message));
return null;
}

public static void work(MessageLivingHurt message) {
EntityPlayer player = ToroHUD.PROXY.getPlayer();
Entity e = player.getEntityWorld().getEntityByID(message.id);
if (e instanceof EntityLivingBase) {
ToroHUD.PROXY.displayDamageDealt((EntityLivingBase)e, message.amount);
ToroHUD.PROXY.displayDamageDealt((EntityLivingBase) e, message.amount);
}
}

@Override
public IMessage onMessage(final MessageLivingHurt message, MessageContext ctx) {
Minecraft.getMinecraft().addScheduledTask(() -> work(message));
return null;
}
}
}
5 changes: 2 additions & 3 deletions src/main/java/net/torocraft/torohud/proxy/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class ClientProxy extends CommonProxy {
private GuiEntityStatus entityStatusGUI;
private Minecraft mc = Minecraft.getMinecraft();
private Entity pointedEntity;
private int entityIdInCrosshairs = 0;
private int refreshCooldown = 0;

@Override
public void preInit(FMLPreInitializationEvent e) {
Expand Down Expand Up @@ -68,9 +70,6 @@ private void displayParticle(Entity entity, int damage) {
Minecraft.getMinecraft().effectRenderer.addEffect(damageIndicator);
}

private int entityIdInCrosshairs = 0;
private int refreshCooldown = 0;

@Override
public void setEntityInCrosshairs() {
RayTraceResult r = getMouseOver(1.0f);
Expand Down

0 comments on commit b2f87f6

Please sign in to comment.