Skip to content

Commit

Permalink
fix: Dedicated server issues. Fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
jco2641 committed Jan 11, 2019
1 parent ccfde72 commit 611531a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Release 0.4.4

* Bug fix for dedicated server

## Release 0.4.3

* Add 'set' methods to seal API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public void convert(final Object value, final Map<Object,Object> output) {
if (value instanceof ItemStack) {
final AspectList list = AspectHelper.getObjectAspects((ItemStack) value);
final HashMap<Object,Object> out = new HashMap<>();
if(list == null) return;
if(list.size() == 0) return;
for (Aspect a : list.getAspects()) {
out.put(a.getName(), list.getAmount(a));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package jco2641.thaumcomp.events;

import jco2641.thaumcomp.items.ItemSealConnector;
import net.minecraft.client.resources.I18n;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
Expand All @@ -23,7 +24,8 @@ public static void onEvent(ItemTooltipEvent event) {
int[] tag = data.getIntArray("thaumcomp:coord");
String face = EnumFacing.getFront(tag[4]).getName();
String nametag = data.getString("thaumcomp:sealName");
String message = String.format("Bound to: %s Dim: %d X: %d Y: %d Z: %d Face: %s",nametag,tag[3],tag[0],tag[1],tag[2],face);
String sealName = I18n.format(nametag);
String message = String.format("Bound to: %s Dim: %d X: %d Y: %d Z: %d Face: %s",sealName,tag[3],tag[0],tag[1],tag[2],face);
event.getToolTip().add(message);
} else {
//have tag, but not bound - show not bound in tool tip
Expand Down
25 changes: 15 additions & 10 deletions src/main/java/jco2641/thaumcomp/items/ItemSealConnector.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package jco2641.thaumcomp.items;

import jco2641.thaumcomp.Reference;
import jco2641.thaumcomp.ThaumicComputers;
import li.cil.oc.api.Driver;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.resources.I18n;
Expand All @@ -16,6 +17,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
Expand Down Expand Up @@ -60,9 +62,11 @@ public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player
if(data.hasKey("thaumcomp:coord")&&data.hasKey("thaumcomp:sealName")){
int[] tag = data.getIntArray("thaumcomp:coord");
String face = EnumFacing.getFront(tag[4]).getName();
String nametag = data.getString("thaumcomp:sealName");
String message = String.format("Seal connector bound to:\n%s\nDim: %d\nX: %d\nY: %d\nZ: %d\nFace: %s",nametag,tag[3],tag[0],tag[1],tag[2],face);
player.sendMessage(new TextComponentString(message));
String nameTag = data.getString("thaumcomp:sealName");
ITextComponent message = new TextComponentString("Seal connector bound to:\n");
message.appendSibling(new TextComponentTranslation(nameTag));
message.appendText(String.format(" Dim: %d X: %d Y: %d Z: %d Face: %s", tag[3], tag[0], tag[1], tag[2], face));
player.sendMessage(message);
} else {
player.sendMessage(new TextComponentString("Seal connector not bound"));
return new ActionResult<>(EnumActionResult.PASS,stack);
Expand Down Expand Up @@ -91,7 +95,7 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos
int dim = world.provider.getDimension();
ISealEntity se = GolemHelper.getSealEntity(dim, new SealPos(pos, side));
if (se != null) {
if ( se.getOwner() == player.getUniqueID().toString() || player.capabilities.isCreativeMode ) {
if ( se.getOwner().equalsIgnoreCase(player.getUniqueID().toString()) || player.capabilities.isCreativeMode ) {
// I'm binding to my seal, or I'm in creative mode
player.swingArm(hand);
if (!stack.hasTagCompound()) {
Expand All @@ -100,11 +104,10 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos
NBTTagCompound data = stack.getTagCompound();
String sealtype = se.getSeal().getKey();
String sealULName = String.format("item.seal.%s.name",sealtype.split(":")[1]);
String sealName = I18n.format(sealULName);
data.setString("thaumcomp:sealName", sealName);
data.setString("thaumcomp:sealName", sealULName);
data.setIntArray("thaumcomp:coord", new int[]{pos.getX(), pos.getY(), pos.getZ(), dim, side.getIndex()});
ITextComponent message = new TextComponentString("Binding to:\n");
message.appendText(sealName);
message.appendSibling(new TextComponentTranslation(sealULName));
message.appendText(String.format("\nDim: %d\nX: %d\nY: %d\nZ: %d\nFace: %s",dim,pos.getX(),pos.getY(),pos.getZ(),side.getName()));
player.sendMessage(message);

Expand All @@ -122,9 +125,11 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos
if (data.hasKey("thaumcomp:coord") && data.hasKey("thaumcomp:sealName")) {
int[] tag = data.getIntArray("thaumcomp:coord");
String face = EnumFacing.getFront(tag[4]).getName();
String nametag = data.getString("thaumcomp:sealName");
String message = String.format("Seal connector bound to:\n%s\nDim: %d\nX: %d\nY: %d\nZ: %d\nFace: %s", nametag, tag[3], tag[0], tag[1], tag[2], face);
player.sendMessage(new TextComponentString(message));
String nameTag = data.getString("thaumcomp:sealName");
ITextComponent message = new TextComponentString("Seal connector bound to:\n");
message.appendSibling(new TextComponentTranslation(nameTag));
message.appendText(String.format(" Dim: %d X: %d Y: %d Z: %d Face: %s", tag[3], tag[0], tag[1], tag[2], face));
player.sendMessage(message);
} else {
player.sendMessage(new TextComponentString("Seal connector not bound"));
}
Expand Down

0 comments on commit 611531a

Please sign in to comment.