@SubscribeEvent public void onTickEnd(TickEvent.WorldTickEvent event) { // Block swapper updates should only occur on the server if(event.world.isRemote) return; if(event.phase == Phase.END) { int dim = event.world.provider.getDimension(); if(blockSwappers.containsKey(dim)) { Set<BlockSwapper> swappers = blockSwappers.get(dim); Iterator<BlockSwapper> iter = swappers.iterator(); while(iter.hasNext()) { BlockSwapper next = iter.next(); if(next == null || !next.tick()) iter.remove(); } } } }
@SubscribeEvent public void onTickEnd(TickEvent.WorldTickEvent event) { // Block Swapping ticking should only occur on the server if(event.world.isRemote) return; if(event.phase == Phase.END) { int dim = event.world.provider.getDimension(); if(blockSwappers.containsKey(dim)) { Set<BlockSwapper> swappers = blockSwappers.get(dim); // Iterate through all of our swappers, removing any // which no longer need to tick. Iterator<BlockSwapper> swapper = swappers.iterator(); while(swapper.hasNext()) { BlockSwapper next = swapper.next(); // If a null sneaks in or the swapper is done, remove it if(next == null || !next.tick()) swapper.remove(); } } } }
/** * Adds a grass seed block swapper to the world at the provided positiona * and with the provided meta (which designates the type of the grass * being spread). * * Block swappers are only actually created on the server, so a client * calling this method will recieve a marker block swapper which contains * the provided information but is not ticked. * @param world The world the swapper will be in. * @param pos The position of the swapper. * @param meta The meta value representing the type of block being swapped. * @return The created block swapper. */ private static BlockSwapper addBlockSwapper(World world, BlockPos pos, int meta) { BlockSwapper swapper = swapperFromMeta(world, pos, meta); // If a set for the dimension doesn't exist, create it. int dim = world.provider.getDimension(); if(!blockSwappers.containsKey(dim)) blockSwappers.put(dim, new HashSet<>()); // Add the block swapper blockSwappers.get(dim).add(swapper); return swapper; }
/** * Adds a new block swapper to the provided world as the provided player. * Block swappers are only added on the server, and a marker instance * which is not actually ticked but contains the proper passed in * information will be returned to the client. * * @param world The world to add the swapper to. * @param player The player who is responsible for this swapper. * @param stack The Terra Truncator which caused this block swapper. * @param origCoords The original coordinates the swapper should start at. * @param steps The range of the block swapper, in blocks. * @param leaves If true, will treat leaves specially (see the BlockSwapper * documentation). */ private static void addBlockSwapper(World world, EntityPlayer player, ItemStack stack, BlockPos origCoords, int steps, boolean leaves) { BlockSwapper swapper = new BlockSwapper(world, player, stack, origCoords, steps, leaves); // Block swapper registration should only occur on the server if(world.isRemote) return; // If the mapping for this dimension doesn't exist, create it. int dim = world.provider.getDimension(); if(!blockSwappers.containsKey(dim)) blockSwappers.put(dim, new HashSet<>()); // Add the swapper blockSwappers.get(dim).add(swapper); }
if(override.partModelReplacement.containsKey(i)) { overridenPartModels[i] = override.partModelReplacement.get(i).bakeIt(getStateForPart(i, state), format, bakedTextureGetter); if(override.brokenPartModelReplacement.containsKey(i)) { overridenBrokenPartModels[i] = override.brokenPartModelReplacement.get(i).bakeIt(getStateForPart(i, state), format, bakedTextureGetter);
protected SlimeIslandData getIslandData(World world) { int dimensionId = world.provider.getDimension(); if(!islandData.containsKey(dimensionId)) { SlimeIslandData data = (SlimeIslandData) world.getPerWorldStorage().getOrLoadData(SlimeIslandData.class, getDataName()); if(data == null) { data = new SlimeIslandData(getDataName()); world.getPerWorldStorage().setData(getDataName(), data); } islandData.put(dimensionId, data); } return islandData.get(dimensionId); }
/** * {@inheritDoc} */ public boolean connects(int vertex) { return edges.containsKey(vertex); }
/** See {@link gnu.trove.map.hash.TIntObjectHashMap#containsKey(int)} */ public boolean containsKey(int key) { return delegate.containsKey(key); }
/** See {@link gnu.trove.map.hash.TIntObjectHashMap#containsKey(int)} */ public boolean containsKey(int key) { return delegate.containsKey(key); }
public boolean containsNode(int n) { return adjacencies.containsKey(n); }
@Override public ItemStack addMeta(int meta, String name) { if (!this.states.containsKey(meta)) { throw new RuntimeException("Usage of wrong function. Use the addMeta function that has an state paired with it with this implementation"); } return super.addMeta(meta, name); }
@Override public ItemStack addMeta(int meta, String name) { if (!this.states.containsKey(meta)) { throw new RuntimeException("Usage of wrong function. Use the addMeta function that has an state paired with it with this implementation"); } return super.addMeta(meta, name); }
/** * <b>Important:</b> run only in write lock! */ private int generateNewName() { int name; do name = random.nextInt(); while (fromId.containsKey(name)); return name; }
@Override public ItemStack addMeta(int meta, String name) { if (!this.states.containsKey(meta)) { throw new RuntimeException("Usage of wrong function. Use the addMeta function that has an amount paired with it with this implementation"); } return super.addMeta(meta, name); }
private TIntObjectHashMap<ArrayList<IntPair>> hashAllSpans(TextAnnotation ta) { TIntObjectHashMap<ArrayList<IntPair>> allSpans = new TIntObjectHashMap<>(); for (int start = 0; start < ta.size() - 1; start++) { int last = Math.min(ta.size(), start + maxLength); StringBuilder sb = new StringBuilder(); for (int end = start; end < last; end++) { String token = ta.getToken(end); token = token.replaceAll("``", "\"").replaceAll("''", "\""); token = SentenceUtils.convertFromPTBBrackets(token); sb.append(token).append(" "); int hash = sb.toString().trim().hashCode(); if (!allSpans.containsKey(hash)) allSpans.put(hash, new ArrayList<>()); List<IntPair> object = allSpans.get(hash); object.add(new IntPair(start, end + 1)); } } return allSpans; }
private TIntObjectHashMap<ArrayList<IntPair>> hashAllSpans(TextAnnotation ta) { TIntObjectHashMap<ArrayList<IntPair>> allSpans = new TIntObjectHashMap<>(); for (int start = 0; start < ta.size() - 1; start++) { int last = Math.min(ta.size(), start + maxLength); StringBuilder sb = new StringBuilder(); for (int end = start; end < last; end++) { String token = ta.getToken(end); token = token.replaceAll("``", "\"").replaceAll("''", "\""); token = SentenceUtils.convertFromPTBBrackets(token); sb.append(token).append(" "); int hash = sb.toString().trim().hashCode(); if (!allSpans.containsKey(hash)) allSpans.put(hash, new ArrayList<>()); List<IntPair> object = allSpans.get(hash); object.add(new IntPair(start, end + 1)); } } return allSpans; }
/** * Create a constant boolean variable equal to 1 if <i>value</i> is true and 0 otherwise * @param name name of the variable * @param value constant value of the boolean variable (true or false) * @return a constant of type BoolVar */ default BoolVar boolVar(String name, boolean value) { int intVal = value ? 1 : 0; if (name.equals(CSTE_NAME + intVal) && ref().getCachedConstants().containsKey(intVal)) { return (BoolVar) ref().getCachedConstants().get(intVal); } BoolVar cste = new FixedBoolVarImpl(name, intVal, ref()); if (name.equals(CSTE_NAME + intVal)) { ref().getCachedConstants().put(intVal, cste); } return cste; }
/** * Create a constant integer variable equal to <i>value</i> * @param name name of the variable * @param value value of the variable * @return a constant IntVar of domain {<i>value</i>} */ default IntVar intVar(String name, int value) { checkIntDomainRange(name, value, value); if (value == 0 || value == 1) { return boolVar(name, value == 1); } if (name.equals(CSTE_NAME + value) && ref().getCachedConstants().containsKey(value)) { return ref().getCachedConstants().get(value); } IntVar cste = new FixedIntVarImpl(name, value, ref()); if (name.equals(CSTE_NAME + value)) { ref().getCachedConstants().put(value, cste); } return cste; }
@Override public boolean remove(VM vm) { if (place.containsKey(vm.id())) { Node n = this.place.remove(vm.id()); //The VM exists and is already placed if (st.get(vm.id()) == RUNNING_STATE) { host[RUNNING_STATE].get(n.id()).remove(vm); } else if (st.get(vm.id()) == SLEEPING_STATE) { host[SLEEPING_STATE].get(n.id()).remove(vm); } st.remove(vm.id()); return true; } else if (st.get(vm.id()) == READY_STATE) { vmReady.remove(vm); st.remove(vm.id()); return true; } return false; }
/** * Get the value of variable s in this solution. * If <i>v</i> was not instantiated during solution recording, calling this method will throw an exception. * * @param s SetVar * @return the value of variable s in this solution, or null if the variable is not instantiated in the solution. * @exception SolverException if <i>v</i> was not instantiated during solution recording. */ public int[] getSetVal(SetVar s) { if (empty) { throw new SolverException("Cannot access value of " + s + ": No solution has been recorded yet (empty solution). Make sure this.record() has been called."); } if (setmap != null && setmap.containsKey(s.getId())) { return setmap.get(s.getId()); } else if ((s.getTypeAndKind() & Variable.TYPE) == Variable.CSTE) { return s.getValue().toArray(); } else { throw new SolverException("Cannot access value of " + s + ": This variable has not been declared to be recorded in the Solution object (see Solution constructor)."); } }