Skip to content

Commit

Permalink
gradelized patch
Browse files Browse the repository at this point in the history
I'm not including this until it can be gradle-ized for sake of public compilation
  • Loading branch information
NextdoorPsycho committed Mar 16, 2023
1 parent 367de5a commit 807ed2b
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 105 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {
id "de.undercouch.download" version "5.0.1"
}

version '2.4.2-1.19.3'
version '2.4.3-1.19.3'
def nmsVersion = "1.19.3" //[NMS]
def apiVersion = '1.19'
def specialSourceVersion = '1.11.0' //[NMS]
Expand Down
204 changes: 102 additions & 102 deletions src/main/java/com/volmit/iris/core/link/CustomItemsDataProvider.java
Original file line number Diff line number Diff line change
@@ -1,102 +1,102 @@
package com.volmit.iris.core.link;

import com.jojodmo.customitems.api.CustomItemsAPI;
import com.jojodmo.customitems.item.custom.CustomItem;
import com.jojodmo.customitems.item.custom.block.CustomMushroomBlock;
import com.jojodmo.customitems.version.SafeMaterial;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.reflect.WrappedField;
import com.volmit.iris.util.reflect.WrappedReturningMethod;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.MultipleFacing;
import org.bukkit.inventory.ItemStack;

import java.util.Map;
import java.util.MissingResourceException;

public class CustomItemsDataProvider extends ExternalDataProvider {

private static final String FIELD_FACES = "faces";
private static final String METHOD_GET_MATERIAL = "getMaterial";

private WrappedField<CustomMushroomBlock, Map<Integer, boolean[]>> mushroomFaces;
private WrappedReturningMethod<CustomMushroomBlock, SafeMaterial> mushroomMaterial;

public CustomItemsDataProvider() {
super("CustomItems");
}

@Override
public void init() {
this.mushroomFaces = new WrappedField<>(CustomMushroomBlock.class, FIELD_FACES);
this.mushroomMaterial = new WrappedReturningMethod<>(CustomMushroomBlock.class, METHOD_GET_MATERIAL);
}

@Override
public BlockData getBlockData(Identifier blockId) throws MissingResourceException {
CustomItem item = CustomItem.get(blockId.key());
if(item == null) {
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
} else if(item.getBlockTexture().isSpawner()) {
throw new MissingResourceException("Iris does not yet support SpawnerBlocks from CustomItems.", blockId.namespace(), blockId.key());
} else if(item.getBlockTexture() != null && item.getBlockTexture().isValid()) {
throw new MissingResourceException("Tried to fetch BlockData for a CustomItem that is not placeable!", blockId.namespace(), blockId.key());
}
return getMushroomData(item);
}

@Override
public ItemStack getItemStack(Identifier itemId) throws MissingResourceException {
ItemStack stack = CustomItemsAPI.getCustomItem(itemId.key());
if(stack == null) {
throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key());
}
return stack;
}

@Override
public Identifier[] getBlockTypes() {
KList<Identifier> names = new KList<>();
for (String name : CustomItemsAPI.listBlockCustomItemIDs()) {
try {
Identifier key = new Identifier("cui", name);
if (getItemStack(key) != null)
names.add(key);
} catch (MissingResourceException ignored) { }
}

return names.toArray(new Identifier[0]);
}

@Override
public Identifier[] getItemTypes() {
KList<Identifier> names = new KList<>();
for (String name : CustomItemsAPI.listCustomItemIDs()) {
try {
Identifier key = new Identifier("cui", name);
if (getItemStack(key) != null)
names.add(key);
} catch (MissingResourceException ignored) { }
}

return names.toArray(new Identifier[0]);
}

@Override
public boolean isValidProvider(Identifier key, boolean isItem) {
return key.namespace().equalsIgnoreCase("cui");
}

private BlockData getMushroomData(CustomItem item) {
MultipleFacing data = (MultipleFacing)mushroomMaterial.invoke(item.getBlockTexture().getMushroomId()).parseMaterial().createBlockData();
boolean[] values = mushroomFaces.get().get(item.getBlockTexture().getMushroomId());
data.setFace(BlockFace.DOWN, values[0]);
data.setFace(BlockFace.EAST, values[1]);
data.setFace(BlockFace.NORTH, values[2]);
data.setFace(BlockFace.SOUTH, values[3]);
data.setFace(BlockFace.UP, values[4]);
data.setFace(BlockFace.WEST, values[5]);
return data;
}
}
//package com.volmit.iris.core.link;
//
//import com.jojodmo.customitems.api.CustomItemsAPI;
//import com.jojodmo.customitems.item.custom.CustomItem;
//import com.jojodmo.customitems.item.custom.block.CustomMushroomBlock;
//import com.jojodmo.customitems.version.SafeMaterial;
//import com.volmit.iris.util.collection.KList;
//import com.volmit.iris.util.reflect.WrappedField;
//import com.volmit.iris.util.reflect.WrappedReturningMethod;
//import org.bukkit.block.BlockFace;
//import org.bukkit.block.data.BlockData;
//import org.bukkit.block.data.MultipleFacing;
//import org.bukkit.inventory.ItemStack;
//
//import java.util.Map;
//import java.util.MissingResourceException;
//
//public class CustomItemsDataProvider extends ExternalDataProvider {
//
// private static final String FIELD_FACES = "faces";
// private static final String METHOD_GET_MATERIAL = "getMaterial";
//
// private WrappedField<CustomMushroomBlock, Map<Integer, boolean[]>> mushroomFaces;
// private WrappedReturningMethod<CustomMushroomBlock, SafeMaterial> mushroomMaterial;
//
// public CustomItemsDataProvider() {
// super("CustomItems");
// }
//
// @Override
// public void init() {
// this.mushroomFaces = new WrappedField<>(CustomMushroomBlock.class, FIELD_FACES);
// this.mushroomMaterial = new WrappedReturningMethod<>(CustomMushroomBlock.class, METHOD_GET_MATERIAL);
// }
//
// @Override
// public BlockData getBlockData(Identifier blockId) throws MissingResourceException {
// CustomItem item = CustomItem.get(blockId.key());
// if(item == null) {
// throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
// } else if(item.getBlockTexture().isSpawner()) {
// throw new MissingResourceException("Iris does not yet support SpawnerBlocks from CustomItems.", blockId.namespace(), blockId.key());
// } else if(item.getBlockTexture() != null && item.getBlockTexture().isValid()) {
// throw new MissingResourceException("Tried to fetch BlockData for a CustomItem that is not placeable!", blockId.namespace(), blockId.key());
// }
// return getMushroomData(item);
// }
//
// @Override
// public ItemStack getItemStack(Identifier itemId) throws MissingResourceException {
// ItemStack stack = CustomItemsAPI.getCustomItem(itemId.key());
// if(stack == null) {
// throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key());
// }
// return stack;
// }
//
// @Override
// public Identifier[] getBlockTypes() {
// KList<Identifier> names = new KList<>();
// for (String name : CustomItemsAPI.listBlockCustomItemIDs()) {
// try {
// Identifier key = new Identifier("cui", name);
// if (getItemStack(key) != null)
// names.add(key);
// } catch (MissingResourceException ignored) { }
// }
//
// return names.toArray(new Identifier[0]);
// }
//
// @Override
// public Identifier[] getItemTypes() {
// KList<Identifier> names = new KList<>();
// for (String name : CustomItemsAPI.listCustomItemIDs()) {
// try {
// Identifier key = new Identifier("cui", name);
// if (getItemStack(key) != null)
// names.add(key);
// } catch (MissingResourceException ignored) { }
// }
//
// return names.toArray(new Identifier[0]);
// }
//
// @Override
// public boolean isValidProvider(Identifier key, boolean isItem) {
// return key.namespace().equalsIgnoreCase("cui");
// }
//
// private BlockData getMushroomData(CustomItem item) {
// MultipleFacing data = (MultipleFacing)mushroomMaterial.invoke(item.getBlockTexture().getMushroomId()).parseMaterial().createBlockData();
// boolean[] values = mushroomFaces.get().get(item.getBlockTexture().getMushroomId());
// data.setFace(BlockFace.DOWN, values[0]);
// data.setFace(BlockFace.EAST, values[1]);
// data.setFace(BlockFace.NORTH, values[2]);
// data.setFace(BlockFace.SOUTH, values[3]);
// data.setFace(BlockFace.UP, values[4]);
// data.setFace(BlockFace.WEST, values[5]);
// return data;
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public class ExternalDataSVC implements IrisService {
@Override
public void onEnable() {
addProvider(
// new CustomItemsDataProvider(), //need this to be gradelized before i can add it to the master repo
new OraxenDataProvider(),
new ItemAdderDataProvider(),
new CustomItemsDataProvider());
new ItemAdderDataProvider());
}

@Override
Expand Down

0 comments on commit 807ed2b

Please sign in to comment.