Skip to content

Commit

Permalink
Remove dependency on #227 (Part 1: Revert "String -> Identifier. WIP.")
Browse files Browse the repository at this point in the history
This reverts commit 5e56559.

# Conflicts:
#	minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/BlockConverter.java
#	minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/ItemConverter.java
#	minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/BlockConverter.java
#	minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/ItemConverter.java
#	src/main/java/nova/core/util/registry/Factory.java
  • Loading branch information
ExE-Boss committed Jan 11, 2017
1 parent ce427c5 commit 0f0a06e
Show file tree
Hide file tree
Showing 53 changed files with 115 additions and 369 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
*/
public class MinecraftItemIngredient extends SpecificItemIngredient {
public MinecraftItemIngredient(net.minecraft.item.ItemStack itemStack) {
super(((Item) Game.natives().toNova(itemStack)).getID().asString()); // TODO?
super(((Item) Game.natives().toNova(itemStack)).getID());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private static ItemIngredient getIngredient(Object ingredient) {
if (ingredient == null) {
return null;
} else if (ingredient instanceof ItemStack) {
return new SpecificItemIngredient(((Item) Game.natives().toNova(ingredient)).getID().asString()); // TODO?
return new SpecificItemIngredient(((Item) Game.natives().toNova(ingredient)).getID());
} else if (ingredient instanceof String) {
return new OreItemIngredient((String) ingredient);
} else if (ingredient instanceof List) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,8 @@ private void registerNovaBlock(BlockFactory blockFactory) {
FWBlock blockWrapper = new FWBlock(blockFactory);
blockFactoryMap.put(blockFactory, blockWrapper);
NovaMinecraft.proxy.registerBlock(blockWrapper);
String blockId = blockFactory.getID().asString(); // TODO?
// GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockId.contains(":") ? blockId : modId + ":" + blockId);
registerNovaBlock(blockWrapper, blockId);
// GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockFactory.getID());
registerNovaBlock(blockWrapper, blockFactory.getID());

if (blockWrapper.dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) {
//Add into creative tab
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public FWBlock(BlockFactory factory) {
this.factory = factory;
this.dummy = factory.build();
this.blockClass = dummy.getClass();
this.setBlockName(dummy.getID().asString()); // TODO?
this.setBlockName(dummy.getID());

// Recalculate super constructor things after loading the block properly
this.opaque = isOpaqueCube();
Expand Down Expand Up @@ -169,7 +169,7 @@ public boolean hasTileEntity(int metadata) {

@Override
public TileEntity createTileEntity(World world, int metadata) {
return FWTileLoader.loadTile(dummy.getID().asString()); // TODO?
return FWTileLoader.loadTile(dummy.getID());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import nova.core.entity.EntityFactory;
import nova.core.item.Item;
import nova.core.sound.Sound;
import nova.core.util.id.Identifier;
import nova.core.util.id.StringIdentifier;
import nova.core.util.shape.Cuboid;
import nova.core.world.World;
import nova.core.wrapper.mc.forge.v17.launcher.NovaMinecraft;
Expand Down Expand Up @@ -146,12 +144,12 @@ public Optional<Entity> getEntity(String uniqueID) {
}

@Override
public Identifier getID() {
return new StringIdentifier(world().provider.getDimensionName());
public String getID() {
return world().provider.getDimensionName();
}

@Override
public void playSoundAtPosition(Vector3D position, Sound sound) {
world().playSound(position.getX(), position.getY(), position.getZ(), sound.getID().asString(), sound.pitch, sound.volume, false);
world().playSound(position.getX(), position.getY(), position.getZ(), sound.getID(), sound.pitch, sound.volume, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import nova.core.entity.Entity;
import nova.core.entity.component.Living;
import nova.core.entity.component.Player;
import nova.core.util.id.Identifier;
import nova.core.util.id.UUIDIdentifier;
import nova.core.wrapper.mc.forge.v17.wrapper.entity.forward.MCEntityTransform;
import nova.core.wrapper.mc.forge.v17.wrapper.inventory.BWInventory;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
Expand Down Expand Up @@ -90,8 +88,8 @@ public String getUsername() {
}

@Override
public Identifier getID() {
return new UUIDIdentifier(entity.getGameProfile().getId());
public String getID() {
return entity.getGameProfile().getId().toString();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ protected void writeEntityToNBT(NBTTagCompound nbt) {
((Storable) wrapped).save(data);
DataWrapper.instance().toNative(nbt, data);
}
nbt.setString("novaID", wrapped.getID().asString()); // TODO?
nbt.setString("novaID", wrapped.getID());
}

@Override
public void writeSpawnData(ByteBuf buffer) {
//Write the ID of the entity to client
String id = wrapped.getID().asString(); // TODO?
String id = wrapped.getID();
char[] chars = id.toCharArray();
buffer.writeInt(chars.length);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ public net.minecraft.item.ItemStack makeItemStack(int stackSize) {

@Override
public String toString() {
return getID().asString(); // TODO?
return getID();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class FWItem extends net.minecraft.item.Item implements ItemWrapperMethod

public FWItem(ItemFactory item) {
this.itemFactory = item;
setUnlocalizedName(item.getID().asString()); // TODO?
setUnlocalizedName(item.getID());
setMaxStackSize(item.build().getMaxCount());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public ItemStack toNative(Item item) {
if (item instanceof BWItem) {
return ((BWItem) item).makeItemStack(item.count());
} else {
ItemFactory itemFactory = Game.items().get(item.getID().asString()).get(); // TODO?
ItemFactory itemFactory = Game.items().get(item.getID()).get();
FWNBTTagCompound tag = new FWNBTTagCompound(item);

MinecraftItemMapping mapping = get(itemFactory);
Expand Down Expand Up @@ -164,6 +164,7 @@ public net.minecraft.item.ItemStack updateMCItemStack(ItemStack itemStack, nova.
/**
* Register all Nova blocks
*/
@Override
public void preInit() {
registerNOVAItemsToMinecraft();
registerMinecraftItemsToNOVA();
Expand Down Expand Up @@ -196,9 +197,9 @@ private void registerNOVAItem(ItemFactory itemFactory) {
if (itemWrapper == null) {
throw new InitializationException("ItemConverter: Missing block: " + itemFactory.getID());
}
if (!itemFactory.getID().asString().equals(net.minecraft.item.Item.itemRegistry.getNameForObject(itemWrapper))) {
if (!itemFactory.getID().equals(net.minecraft.item.Item.itemRegistry.getNameForObject(itemWrapper))) {
System.err.println("[NOVA]: ItemConverter: " + net.minecraft.item.Item.itemRegistry.getNameForObject(itemWrapper) + " != " + itemFactory.getID());
net.minecraft.item.Item newItemWrapper = (net.minecraft.item.Item)net.minecraft.item.Item.itemRegistry.getObject(itemFactory.getID().asString());
net.minecraft.item.Item newItemWrapper = (net.minecraft.item.Item)net.minecraft.item.Item.itemRegistry.getObject(itemFactory.getID());
itemWrapper = newItemWrapper != null ? newItemWrapper : itemWrapper;
}
} else {
Expand All @@ -211,9 +212,8 @@ private void registerNOVAItem(ItemFactory itemFactory) {
// Don't register ItemBlocks twice
if (!(dummy instanceof ItemBlock)) {
NovaMinecraft.proxy.registerItem((FWItem) itemWrapper);
String itemId = itemFactory.getID().asString(); // TODO?
//GameRegistry.registerItem(itemWrapper, itemId);
registerNovaItem((FWItem) itemWrapper, itemId);
// GameRegistry.registerItem(itemWrapper, itemFactory.getID());
registerNovaItem((FWItem) itemWrapper, itemFactory.getID());

if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) {
//Add into creative tab
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
*/
public class MinecraftItemIngredient extends SpecificItemIngredient {
public MinecraftItemIngredient(net.minecraft.item.ItemStack itemStack) {
super(((Item) Game.natives().toNova(itemStack)).getID().asString()); // TODO?
super(((Item) Game.natives().toNova(itemStack)).getID());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private static ItemIngredient getIngredient(Object ingredient) {
if (ingredient == null) {
return null;
} else if (ingredient instanceof ItemStack) {
return new SpecificItemIngredient(((Item) Game.natives().toNova(ingredient)).getID().asString()); // TODO?
return new SpecificItemIngredient(((Item) Game.natives().toNova(ingredient)).getID());
} else if (ingredient instanceof String) {
return new OreItemIngredient((String) ingredient);
} else if (ingredient instanceof List) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ public boolean canReplace() {
private void registerNovaBlock(BlockFactory blockFactory) {
FWBlock blockWrapper = new FWBlock(blockFactory);
blockFactoryMap.put(blockFactory, blockWrapper);
String blockId = blockFactory.getID().asString(); // TODO?
registerNovaBlock(blockWrapper, blockId);
// GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockFactory.getID());
registerNovaBlock(blockWrapper, blockFactory.getID());
NovaMinecraft.proxy.postRegisterBlock(blockWrapper);

if (blockWrapper.dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public FWBlock(BlockFactory factory) {
this.stepSound = soundTypeStone;
}
this.blockClass = dummy.getClass();
this.setUnlocalizedName(dummy.getID().asString()); // TODO?
this.setUnlocalizedName(dummy.getID());

// Recalculate super constructor things after loading the block properly
this.fullBlock = isOpaqueCube();
Expand Down Expand Up @@ -179,7 +179,7 @@ public boolean hasTileEntity(IBlockState state) {

@Override
public TileEntity createTileEntity(World world, IBlockState state) {
FWTile fwTile = FWTileLoader.loadTile(dummy.getID().asString()); // TODO?
FWTile fwTile = FWTileLoader.loadTile(dummy.getID());
if (lastExtendedStatePos != null) {
fwTile.block.components.getOrAdd(new MCBlockTransform(dummy, Game.natives().toNova(world), new Vector3D(lastExtendedStatePos.getX(), lastExtendedStatePos.getY(), lastExtendedStatePos.getZ())));
lastExtendedStatePos = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public String getBreakSound() {
if (sound.domain.isEmpty() && !sound.name.contains(".")) {
return "dig." + sound.name;
}
return sound.getID().asString(); // TODO?
return sound.getID();
}
return super.getBreakSound();
}
Expand All @@ -38,7 +38,7 @@ public String getStepSound() {
if (sound.domain.isEmpty() && !sound.name.contains(".")) {
return "step." + sound.name;
}
return sound.getID().asString(); // TODO?
return sound.getID();
}
return super.getStepSound();
}
Expand All @@ -50,7 +50,7 @@ public String getPlaceSound() {
if (sound.domain.isEmpty()) {
return sound.name;
}
return sound.getID().asString(); // TODO?
return sound.getID();
}
// By default MC uses the block break sound for block placement
return this.getBreakSound();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import nova.core.entity.EntityFactory;
import nova.core.item.Item;
import nova.core.sound.Sound;
import nova.core.util.id.Identifier;
import nova.core.util.id.StringIdentifier;
import nova.core.util.shape.Cuboid;
import nova.core.world.World;
import nova.core.wrapper.mc.forge.v18.launcher.NovaMinecraft;
Expand Down Expand Up @@ -155,12 +153,12 @@ public Optional<Entity> getEntity(String uniqueID) {
}

@Override
public Identifier getID() {
return new StringIdentifier(world().provider.getDimensionName());
public String getID() {
return world().provider.getDimensionName();
}

@Override
public void playSoundAtPosition(Vector3D position, Sound sound) {
world().playSoundEffect(position.getX(), position.getY(), position.getZ(), sound.getID().asString(), sound.volume, sound.pitch);
world().playSoundEffect(position.getX(), position.getY(), position.getZ(), sound.getID(), sound.volume, sound.pitch);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import nova.core.entity.Entity;
import nova.core.entity.component.Living;
import nova.core.entity.component.Player;
import nova.core.util.id.Identifier;
import nova.core.util.id.UUIDIdentifier;
import nova.core.wrapper.mc.forge.v18.wrapper.entity.forward.MCEntityTransform;
import nova.core.wrapper.mc.forge.v18.wrapper.inventory.BWInventory;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
Expand Down Expand Up @@ -90,8 +88,8 @@ public String getUsername() {
}

@Override
public Identifier getID() {
return new UUIDIdentifier(entity.getGameProfile().getId());
public String getID() {
return entity.getGameProfile().getId().toString();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ protected void writeEntityToNBT(NBTTagCompound nbt) {
((Storable) wrapped).save(data);
DataWrapper.instance().toNative(nbt, data);
}
nbt.setString("novaID", wrapped.getID().asString()); // TODO?
nbt.setString("novaID", wrapped.getID());
}

@Override
public void writeSpawnData(ByteBuf buffer) {
//Write the ID of the entity to client
String id = wrapped.getID().asString(); // TODO?
String id = wrapped.getID();
char[] chars = id.toCharArray();
buffer.writeInt(chars.length);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ public ItemStack makeItemStack(int stackSize) {

@Override
public String toString() {
return getID().asString(); // TODO?
return getID();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class FWItem extends net.minecraft.item.Item implements ItemWrapperMethod

public FWItem(ItemFactory item) {
this.itemFactory = item;
setUnlocalizedName(item.getID().asString()); // TODO?
setUnlocalizedName(item.getID());
setMaxStackSize(item.build().getMaxCount());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public ItemStack toNative(Item item) {
if (item instanceof BWItem) {
return ((BWItem) item).makeItemStack(item.count());
} else {
ItemFactory itemFactory = Game.items().get(item.getID().asString()).get();// TODO?
ItemFactory itemFactory = Game.items().get(item.getID()).get();
FWNBTTagCompound tag = new FWNBTTagCompound(item);

MinecraftItemMapping mapping = get(itemFactory);
Expand Down Expand Up @@ -166,6 +166,7 @@ public ItemStack updateMCItemStack(ItemStack itemStack, Item item) {
/**
* Register all Nova blocks
*/
@Override
public void preInit() {
registerNOVAItemsToMinecraft();
registerMinecraftItemsToNOVA();
Expand Down Expand Up @@ -198,9 +199,9 @@ private void registerNOVAItem(ItemFactory itemFactory) {
if (itemWrapper == null) {
throw new InitializationException("ItemConverter: Missing block: " + itemFactory.getID());
}
if (!itemFactory.getID().asString().equals(net.minecraft.item.Item.itemRegistry.getNameForObject(itemWrapper))) {
if (!itemFactory.getID().equals(net.minecraft.item.Item.itemRegistry.getNameForObject(itemWrapper))) {
System.err.println("[NOVA]: ItemConverter: " + net.minecraft.item.Item.itemRegistry.getNameForObject(itemWrapper) + " != " + itemFactory.getID());
net.minecraft.item.Item newItemWrapper = net.minecraft.item.Item.getByNameOrId(itemFactory.getID().asString());
net.minecraft.item.Item newItemWrapper = net.minecraft.item.Item.getByNameOrId(itemFactory.getID());
itemWrapper = newItemWrapper != null ? newItemWrapper : itemWrapper;
}
} else {
Expand All @@ -213,8 +214,8 @@ private void registerNOVAItem(ItemFactory itemFactory) {
// Don't register ItemBlocks twice
if (!(dummy instanceof ItemBlock)) {
NovaMinecraft.proxy.registerItem((FWItem) itemWrapper);
String itemId = itemFactory.getID().asString(); // TODO?
GameRegistry.registerItem(itemWrapper, itemId);
// GameRegistry.registerItem(itemWrapper, itemFactory.getID());
registerNovaItem((FWItem) itemWrapper, itemFactory.getID());

if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) {
//Add into creative tab
Expand All @@ -238,7 +239,7 @@ private void registerNOVAItem(ItemFactory itemFactory) {
/**
* Prevent forge from prefixing item IDs with "nova:"
*/
private void registerNovaBlock(FWItem itemWrapper, String blockId) {
private void registerNovaItem(FWItem itemWrapper, String blockId) {
try {
Class<GameData> gameDataClass = GameData.class;
Method getMain = gameDataClass.getDeclaredMethod("getMain");
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/nova/core/block/Block.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
import nova.core.item.Item;
import nova.core.item.ItemFactory;
import nova.core.util.Direction;
import nova.core.util.id.Identifiable;
import nova.core.util.id.Identifier;
import nova.core.util.Identifiable;
import nova.core.world.World;
import nova.internal.core.Game;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
Expand Down Expand Up @@ -60,7 +59,7 @@ public final BlockFactory getFactory() {
}

@Override
public final Identifier getID() {
public final String getID() {
return getFactory().getID();
}

Expand Down
Loading

0 comments on commit 0f0a06e

Please sign in to comment.